Created
March 14, 2023 23:09
-
-
Save shurane/b3e3f3ce9bc3d32328854e929c9f029c to your computer and use it in GitHub Desktop.
HammerSpoon configuration for MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://gist.github.com/nyergler/7056c61174194a9af9b4d5d727f1b566 | |
-- Magnet replacement bindings | |
hs.hotkey.bind({"ctrl", "alt"}, "left", function() | |
-- size focused window to left half of display | |
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) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "a", function() | |
-- size focused window to left third of display | |
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 / 3 | |
f.h = max.h | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "s", function() | |
-- size focused window to middle third of display | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.x + (max.w / 3) | |
f.y = max.y | |
f.w = max.w / 3 | |
f.h = max.h | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "d", function() | |
-- size focused window to right third of display | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.x + (max.w / 3 * 2) | |
f.y = max.y | |
f.w = max.w / 3 | |
f.h = max.h | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "right", function() | |
-- size focused window to right half of display | |
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) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "return", function() | |
-- size focused window to size of desktop | |
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) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "g", function() | |
-- size focused window to mostly maximized (1/8 diagonal to 6/8 diagonal) | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.x + max.w / 8 | |
f.y = max.y + max.h / 8 | |
f.w = max.w * 6 / 8 | |
f.h = max.h * 6 / 8 | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "h", function() | |
-- size focused window to mostly maximized (1/16 diagonal to 15/16 diagonal) | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.x + max.w / 16 | |
f.y = max.y + max.h / 16 | |
f.w = max.w * 14 / 16 | |
f.h = max.h * 14 / 16 | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind({"ctrl", "alt"}, "j", function() | |
-- size focused window to mostly maximized (1/64 diagonal to 63/64 diagonal) | |
local win = hs.window.focusedWindow() | |
local f = win:frame() | |
local screen = win:screen() | |
local max = screen:frame() | |
f.x = max.x + max.w / 64 | |
f.y = max.y + max.h / 64 | |
f.w = max.w * 62 / 64 | |
f.h = max.h * 62 / 64 | |
win:setFrame(f) | |
end) | |
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "F", function() | |
-- toggle the focused window to full screen (workspace) | |
local win = hs.window.focusedWindow() | |
win:setFullScreen(not win:isFullScreen()) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment