Window snapping

This commit is contained in:
Josh Sherman 2022-05-31 21:59:46 -05:00
parent 4c71424005
commit 00dad3db06
No known key found for this signature in database
GPG key ID: 55B058A80530EF22

View file

@ -1 +1,60 @@
-- TODO: Make it hot.
-- Window 50% left
hs.hotkey.bind({"cmd"}, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f, 0)
end)
-- Window 50% right
hs.hotkey.bind({"cmd"}, "Right", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + (max.w / 2)
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f, 0)
end)
-- Window 100%
hs.hotkey.bind({"cmd"}, "Up", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w
f.h = max.h
win:setFrame(f, 0)
end)
-- Window "Reset"
hs.hotkey.bind({"cmd"}, "Down", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f, 0)
win:centerOnScreen(screen, true, 0)
end)