Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hammerspoon init script that allows 1-9 to move windows into 9ths of the screen
function move_to_third(r,c)
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local extents = screen:frame()
f.x = extents.x + (extents.w / 3) * c
f.y = extents.y + (extents.h / 3) * r
f.w = extents.w / 3
f.h = extents.h / 3
win:setFrame(f)
end
for i=1,9 do
hs.hotkey.bind({"cmd", "alt", "ctrl"}, tostring(i), function()
move_to_third(math.floor((i-1)/3),(i-1)%3)
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment