A window management configuration for Hammerspoon focused on usage with ultrawide monitors and keybinds.
Install Hammerspoon using brew:
brew install hammerspoon
Make sure Hammerspoon is started (You should see the a Hammerspoon logo in your menubar).
Download the latest release. Unzip it and open the spoon.
Hammerspoon should prompt that the newly installed spoon is now available.
Click on the Hammerspoon menubar icon and click on 'Open Config'. An init.lua
file should now open in your editor of choice.
Paste the following configuration in the init.lua
file, save it and close it.
hs.loadSpoon("ultrawide")
spoon.ultrawide:bindHotkeys({})
Click on the Hammerspoon menubar icon again, and click on 'Reload Config'.
ctrl(^) + alt(⌥) + cmd(⌘) + left
Snap current window to the left fourth to the screenctrl(^) + alt(⌥) + cmd(⌘) + right
Snap current window to the right fourth to the screenctrl(^) + alt(⌥) + cmd(⌘) + m
Snap current window to the center half of the screen
ctrl(^) + alt(⌥) + cmd(⌘) + 1
Snap current window to the left top eigth to the screenctrl(^) + alt(⌥) + cmd(⌘) + 2
Snap current window to the right top eigth to the screenctrl(^) + alt(⌥) + cmd(⌘) + 3
Snap current window to the left bottom eigth to the screenctrl(^) + alt(⌥) + cmd(⌘) + 4
Snap current window to the right bottom eigth to the screen
ctrl(^) + alt(⌥) + cmd(⌘) + up
Keep the current width, but changes window position to top halfctrl(^) + alt(⌥) + cmd(⌘) + down
Keep the current width, but changes window position to bottom half
ctrl(^) + alt(⌥) + cmd(⌘) + C
Centralize current windowctrl(^) + alt(⌥) + cmd(⌘) + Z
Toggle zoom for current windowctrl(^) + alt(⌥) + cmd(⌘) + N
Move current window to next screenctrl(^) + alt(⌥) + cmd(⌘) + P
Move current window to previous screen
The default key mapping looks like this:
obj.mash = { 'ctrl', 'alt', 'cmd', 'shift' }
obj.mapping = {
left = { obj.mash, 'left' },
right = { obj.mash, 'right' },
up = { obj.mash, 'up' },
down = { obj.mash, 'down' },
upleft = { obj.mash, '1' },
upright = { obj.mash, '3' },
botleft = { obj.mash, '2' },
botright = { obj.mash, '4' },
maximum = { obj.mash, 'm' },
toggleZoom = { obj.mash, 'z' },
center = { obj.mash, 'c' },
nextScreen = { obj.mash, 'n' },
previousScreen = { obj.mash, 'p' }
}
To change your modifier keys you can edit the ob.mash
values, otherwise change the mappings. For example to change the modifier key to F18 and snap left with l:
obj.mash = { 'F18'}
obj.mapping = {
left = {obj.mash, 'l'},
...
}
Credits to @peterklijn for shiftit spoon which was foundation of this project.