Created
January 12, 2025 18:58
-
-
Save dodeja/dfea44b4c92bbe8cb4b6b5f2394c66b7 to your computer and use it in GitHub Desktop.
Dodeja's Hamerspoon config
This file contains hidden or 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
mods = { 'ctrl', 'alt', 'cmd' } | |
units = { | |
bottom = { x = 0.0, y = 0.5, w = 1.0, h = 0.5 }, | |
left = { x = 0.0, y = 0.0, w = 0.5, h = 1.0 }, | |
right = { x = 0.5, y = 0.0, w = 0.5, h = 1.0 }, | |
top = { x = 0.0, y = 0.0, w = 1.0, h = 0.5 }, | |
} | |
animationDuration = 0 | |
function createMoveWindow(rect) | |
return function () | |
hs.window.focusedWindow():move(rect, nil, true, animationDuration) | |
end | |
end | |
hs.hotkey.bind(mods, 'down', createMoveWindow(units.bottom)) | |
hs.hotkey.bind(mods, 'left', createMoveWindow(units.left)) | |
hs.hotkey.bind(mods, 'right', createMoveWindow(units.right)) | |
hs.hotkey.bind(mods, 'up', createMoveWindow(units.top)) | |
hs.hotkey.bind(mods, 'm', function() | |
hs.window.focusedWindow():maximize(animationDuration) | |
end) | |
hs.hotkey.bind(mods, 'c', function() | |
toScreen = nil | |
inBounds = true | |
hs.window.focusedWindow():centerOnScreen(toScreen, inBounds) | |
end | |
) | |
-- Increase window width | |
hs.hotkey.bind(mods, ']', function() | |
local win = hs.window.focusedWindow() | |
local frame = win:frame() | |
frame.w = frame.w + 50 | |
win:setFrame(frame, animationDuration) | |
end) | |
-- Decrease window width | |
hs.hotkey.bind(mods, '[', function() | |
local win = hs.window.focusedWindow() | |
local frame = win:frame() | |
frame.w = frame.w - 50 | |
win:setFrame(frame, animationDuration) | |
end) | |
-- Increase window height | |
hs.hotkey.bind(mods, '=', function() | |
local win = hs.window.focusedWindow() | |
local frame = win:frame() | |
frame.h = frame.h + 50 | |
win:setFrame(frame, animationDuration) | |
end) | |
-- Decrease window height | |
hs.hotkey.bind(mods, '-', function() | |
local win = hs.window.focusedWindow() | |
local frame = win:frame() | |
frame.h = frame.h - 50 | |
win:setFrame(frame, animationDuration) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment