···11+---@diagnostic disable: undefined-global
22+33+local top_padding = 40
44+55+local center_tall = function()
66+ local win = hs.window.focusedWindow()
77+ local f = win:frame()
88+ local screen = win:screen()
99+ local max = screen:frame()
1010+1111+ f.w = 3 * max.w / 5
1212+ f.h = max.h - top_padding
1313+ win:setFrame(f)
1414+ win:centerOnScreen()
1515+ f = win:frame()
1616+ f.y = f.y + 10
1717+ win:setFrame(f)
1818+end
1919+2020+local center = function()
2121+ local win = hs.window.focusedWindow()
2222+ local f = win:frame()
2323+ local screen = win:screen()
2424+ local max = screen:frame()
2525+2626+ f.w = 3 * max.w / 5
2727+ f.h = max.h / 1.5
2828+ win:setFrame(f)
2929+ win:centerOnScreen()
3030+end
3131+3232+hs.hotkey.bind({ "alt", "shift" }, "G", function()
3333+ center_tall()
3434+end)
3535+3636+hs.hotkey.bind({ "alt", "shift" }, "C", function()
3737+ center()
3838+end)
3939+4040+hs.hotkey.bind({ "alt", "ctrl", "shift" }, "R", function()
4141+ hs.reload()
4242+end)
4343+4444+-- Bind Command + ` (Backtick) to cycle windows of the same app
4545+hs.hotkey.bind({ "alt", "shift" }, "N", function()
4646+ local win = hs.window.focusedWindow()
4747+ if not win then
4848+ return
4949+ end
5050+5151+ local app = win:application()
5252+ local appWindows = app:allWindows()
5353+5454+ -- 1. Filter for standard, visible windows
5555+ local validWindows = {}
5656+ for _, w in ipairs(appWindows) do
5757+ if w:isStandard() and w:isVisible() then
5858+ table.insert(validWindows, w)
5959+ end
6060+ end
6161+6262+ if #validWindows < 2 then
6363+ return
6464+ end
6565+6666+ -- 2. SORT the windows by ID to ensure a stable loop order
6767+ table.sort(validWindows, function(a, b)
6868+ return a:id() < b:id()
6969+ end)
7070+7171+ -- 3. Find current index in the sorted list
7272+ local currentIndex = 0
7373+ for i, w in ipairs(validWindows) do
7474+ if w:id() == win:id() then
7575+ currentIndex = i
7676+ break
7777+ end
7878+ end
7979+8080+ -- 4. Calculate next index and focus
8181+ local nextIndex = (currentIndex % #validWindows) + 1
8282+ validWindows[nextIndex]:focus()
8383+end)
8484+hs.alert.show("Config loaded")