Window snapping
This commit is contained in:
parent
4c71424005
commit
00dad3db06
1 changed files with 60 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue