this repo has no description
1local appBindings = {
2 ["1"] = "Firefox",
3 ["2"] = "Slack",
4 ["3"] = "Discord",
5 ["4"] = "Spotify",
6 ["9"] = "Ghostty",
7 ["0"] = "Obsidian",
8}
9
10for key, app in pairs(appBindings) do
11 hs.hotkey.bind({ "cmd", "ctrl" }, key, function()
12 hs.application.launchOrFocus(app)
13 end)
14end
15
16hs.hotkey.bind({ "cmd", "ctrl" }, "r", function()
17 hs.reload()
18end)
19
20-- Window management
21hs.window.animationDuration = 0
22
23local function moveWindow(fn)
24 local win = hs.window.focusedWindow()
25 if not win then return end
26 local screen = win:screen():frame()
27 fn(win, screen)
28end
29
30local windowBindings = {
31 h = function(w, s) w:setFrame({ x = s.x, y = s.y, w = s.w / 2, h = s.h }) end,
32 l = function(w, s) w:setFrame({ x = s.x + s.w / 2, y = s.y, w = s.w / 2, h = s.h }) end,
33 Return = function(w, s) w:setFrame(s) end,
34 u = function(w, s) w:setFrame({ x = s.x, y = s.y, w = s.w / 2, h = s.h / 2 }) end,
35 i = function(w, s) w:setFrame({ x = s.x + s.w / 2, y = s.y, w = s.w / 2, h = s.h / 2 }) end,
36 j = function(w, s) w:setFrame({ x = s.x, y = s.y + s.h / 2, w = s.w / 2, h = s.h / 2 }) end,
37 k = function(w, s) w:setFrame({ x = s.x + s.w / 2, y = s.y + s.h / 2, w = s.w / 2, h = s.h / 2 }) end,
38}
39
40for key, fn in pairs(windowBindings) do
41 hs.hotkey.bind({ "ctrl", "alt" }, key, function() moveWindow(fn) end)
42end
43
44-- Cycling window positions (thirds and 2/3rds)
45local cycleState = { g = 0, e = 0 }
46
47-- g: 1/3 width, cycles right → middle → left
48hs.hotkey.bind({ "ctrl", "alt" }, "g", function()
49 local win = hs.window.focusedWindow()
50 if not win then return end
51 local s = win:screen():frame()
52 local positions = {
53 { x = s.x + s.w * 2 / 3, y = s.y, w = s.w / 3, h = s.h },
54 { x = s.x + s.w / 3, y = s.y, w = s.w / 3, h = s.h },
55 { x = s.x, y = s.y, w = s.w / 3, h = s.h },
56 }
57 cycleState.g = (cycleState.g % #positions) + 1
58 win:setFrame(positions[cycleState.g])
59end)
60
61-- e: 2/3 width, cycles left → right
62hs.hotkey.bind({ "ctrl", "alt" }, "e", function()
63 local win = hs.window.focusedWindow()
64 if not win then return end
65 local s = win:screen():frame()
66 local positions = {
67 { x = s.x, y = s.y, w = s.w * 2 / 3, h = s.h },
68 { x = s.x + s.w / 3, y = s.y, w = s.w * 2 / 3, h = s.h },
69 }
70 cycleState.e = (cycleState.e % #positions) + 1
71 win:setFrame(positions[cycleState.e])
72end)
73
74hs.alert.show("Config loaded")