hammerspoon-shiftit icon indicating copy to clipboard operation
hammerspoon-shiftit copied to clipboard

attempt to index a nil value

Open L33t-HAXXOR opened this issue 3 years ago • 5 comments

Please Wait!

Hear me out.

Before you respond with, "this already has a solution, read the docs" and close the issue, I did do that and am still having an issue with the setup:

Captura de Pantalla 2021-09-06 a la(s) 22 23 47

Running this config: System - Mac Config 2020-12-01

I'm moving on to try the Spooninstall method. Is there a debug log I can send? Is it already posted above?

Thanks for hearing me out!

L33t-HAXXOR avatar Sep 07 '21 03:09 L33t-HAXXOR

Also for the Spooninstall method, will I need to delete the first script I pasted in? Thank you!

L33t-HAXXOR avatar Sep 07 '21 03:09 L33t-HAXXOR

Hi,

Thanks for taking the time to submit an issue. From looking at the print screens, I think there's something wrong with your general Hammerspoon configuration.

Hammerspoon is configured with a init.lua script file that is located in the hidden .hammerspoon directory in your user home folder (~/.hammerspoon/init.lua / /users/YOURUSERNAME/.hammerspoon/init.lua). You can also open it by clicking on the Hammerspoon icon in your menu bar and selecting 'Open Config' in the dropdown.

This file is there you load and start the Hammerspoon ShiftIt plugin. I think there's something wrong with that file.

In my case, my file looks like this:

hs.loadSpoon("ShiftIt")
spoon.ShiftIt:bindHotkeys({})

In addition, I have the following folder structure in the .hammerspoon directory: ~/.hammerspoon/Spoons/ShiftIt.spoon/init.lua.

It's important that the string "ShiftIt" matches with the folder name ending with .spoon, as otherwise it does not load the Hammerspoon ShiftIt plugin and the next line (spoon.ShiftIt:bindHotkeys({})) fails.

Could you please share the content of the ~/.hammerspoon/init.lua file on your machine? As well as run the command ls -la ~/.hammerspoon/Spoons on your machine and copy/paste the results of that command in the comment?

peterklijn avatar Sep 19 '21 13:09 peterklijn

I have the same issue. Here is my log output (I think I setup everything according to your readme):

2021-09-22 21:26:21: -- Lazy extension loading enabled
2021-09-22 21:26:21: -- Loading ~/.hammerspoon/init.lua
2021-09-22 21:26:21: -- Loading Spoon: ShiftIt
2021-09-22 21:26:21: -- Loading extension: hotkey
2021-09-22 21:26:21: 21:26:21     hotkey: Enabled hotkey ⌘⌃⌥LEFT
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥RIGHT
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥UP
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥DOWN
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥1
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥2
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥3
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥4
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥M
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥F
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥Z
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥C
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥N
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥P
2021-09-22 21:26:21: 21:26:21 ** Warning:hs.keycode: key '=' not found in active keymap; using ANSI-standard US keyboard layout as fallback, returning '24'
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥^
2021-09-22 21:26:21:              hotkey: Enabled hotkey ⌘⌃⌥-
2021-09-22 21:26:21: -- Done.
2021-09-22 21:26:35: -- Loading extension: window
2021-09-22 21:26:35: 21:26:35 ERROR:   LuaSkin: hs.hotkey callback: /Users/kue/.hammerspoon/Spoons/ShiftIt.spoon/init.lua:51: attempt to index a nil value
stack traceback:
	/Users/kue/.hammerspoon/Spoons/ShiftIt.spoon/init.lua:51: in function 'move'
	/Users/kue/.hammerspoon/Spoons/ShiftIt.spoon/init.lua:113: in function 'ShiftIt.left'
	/Users/kue/.hammerspoon/Spoons/ShiftIt.spoon/init.lua:161: in function </Users/kue/.hammerspoon/Spoons/ShiftIt.spoon/init.lua:161>

line 161 is: hs.hotkey.bind(self.mapping.left[1], self.mapping.left[2], function() self:left() end)

line 51 is: function move(unit) hs.window.focusedWindow():move(unit, nil, true, 0) end

Running MacOS Big Sur 11.5.2 (20G95)

Update

I enabled Hammerspoon in Privacy > Accessibility Settings of MacOS, and now it works :) (I have not seen this step in the readme).

ideadapt avatar Sep 22 '21 19:09 ideadapt

Thanks for updating the message @ideadapt, I think you have a good point to put it as a step in the installation section. It's mentioned in the Known issue section, but it might be overlooked.

peterklijn avatar Sep 23 '21 06:09 peterklijn

I think you need to download the unzipped file in here into the Spoons (.hammerspoon/Spoons) directory. It works for me after the copying. My Spoons directory was empty.

zc-alexfan avatar Apr 23 '22 14:04 zc-alexfan