main
59c7d64 · 8 days ago 139 commits
  1local vars = require("modules.vars")
  2local mod = "SUPER"
  3
  4-- Window management ─────────────────────────────────────────────────
  5hl.bind(mod .. " + SHIFT + W", hl.dsp.window.close())
  6hl.bind(mod .. " + M", hl.dsp.exit())
  7hl.bind(mod .. " + F", hl.dsp.window.float({ action = "toggle" }))
  8hl.bind(mod .. " + CTRL + F", hl.dsp.window.fullscreen())
  9
 10-- hl.bind("ALT + TAB", function()
 11-- 	hl.dispatch(hl.dsp.window.cycle_next("visible"))
 12-- 	hl.dispatch(hl.dsp.window.bring_to_top())
 13-- end)
 14
 15hl.bind("ALT + TAB", function()
 16	-- 1. Collect the active workspace ID on each monitor
 17	local active_workspaces = {}
 18	for _, m in ipairs(hl.get_monitors()) do
 19		if m.active_workspace then
 20			active_workspaces[m.active_workspace.id] = true
 21		end
 22	end
 23
 24	-- 2. Filter windows to only those on an active (visible) workspace
 25	local windows = {}
 26	for _, w in ipairs(hl.get_windows()) do
 27		if w.workspace and active_workspaces[w.workspace.id] then
 28			table.insert(windows, w)
 29		end
 30	end
 31
 32	if #windows == 0 then
 33		return
 34	end
 35
 36	-- 3. Find current window's position and move to the next one
 37	local active = hl.get_active_window()
 38	local idx = 1
 39	if active then
 40		for i, w in ipairs(windows) do
 41			if w.address == active.address then
 42				idx = i
 43				break
 44			end
 45		end
 46	end
 47
 48	local next_idx = (idx % #windows) + 1
 49	hl.dispatch(hl.dsp.focus({ window = "address:" .. windows[next_idx].address }))
 50	hl.dispatch(hl.dsp.window.bring_to_top())
 51end)
 52
 53-- Swap windows (CTRL + WASD)
 54hl.bind(mod .. " + CTRL + W", hl.dsp.window.swap({ direction = "u" }))
 55hl.bind(mod .. " + CTRL + A", hl.dsp.window.swap({ direction = "l" }))
 56hl.bind(mod .. " + CTRL + S", hl.dsp.window.swap({ direction = "d" }))
 57hl.bind(mod .. " + CTRL + D", hl.dsp.window.swap({ direction = "r" }))
 58
 59-- Scripts and apps ──────────────────────────────────────────────────
 60hl.bind(mod .. " + SPACE", hl.dsp.exec_cmd(vars.menu))
 61hl.bind(mod .. " + T", hl.dsp.exec_cmd(vars.terminal))
 62hl.bind(mod .. " + E", hl.dsp.exec_cmd(vars.fileManager))
 63hl.bind(mod .. " + B", hl.dsp.exec_cmd(vars.browser))
 64hl.bind(mod .. " + L", hl.dsp.exec_cmd(vars.swaylock))
 65hl.bind(mod .. " + R", hl.dsp.exec_cmd(vars.swaybarToggle))
 66hl.bind(mod .. " + V", hl.dsp.exec_cmd(vars.cliphistMenu))
 67hl.bind(mod .. " + period", hl.dsp.exec_cmd(vars.emojiMenu))
 68hl.bind(mod .. " + SHIFT + S", hl.dsp.exec_cmd(vars.screenshotMenu))
 69hl.bind(mod .. " + S", hl.dsp.exec_cmd(vars.cycleSpecial))
 70hl.bind(mod .. " + U", hl.dsp.exec_cmd(vars.handyToggle))
 71
 72-- Workspaces: switch ────────────────────────────────────────────────
 73for i = 1, 9 do
 74	hl.bind(mod .. " + " .. i, hl.dsp.focus({ workspace = i }))
 75	hl.bind(mod .. " + SHIFT + " .. i, hl.dsp.window.move({ workspace = i, follow = false }))
 76end
 77
 78-- Mouse: move / resize ──────────────────────────────────────────────
 79hl.bind(mod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
 80hl.bind(mod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true })
 81
 82-- ── Monitor → workspace range map ─────────────────────────────────────
 83local MONITOR_WS = {
 84	["HDMI-A-2"] = { min = 1, max = 3 },
 85	["DP-1"] = { min = 4, max = 6 },
 86	["HDMI-A-1"] = { min = 7, max = 9 },
 87}
 88
 89-- Returns { min, max } for the focused monitor
 90local function current_range()
 91	local mon = hl.get_active_monitor()
 92	local range = mon and MONITOR_WS[mon.name]
 93	if not range then
 94		-- fallback: unknown monitor, allow full 1-9 range
 95		return { min = 1, max = 9 }
 96	end
 97	return range
 98end
 99
100-- ── Navigation helpers ────────────────────────────────────────────────
101
102-- Go to next ws, stop at monitor's max
103local function ws_next()
104	local ws = hl.get_active_workspace()
105	local range = current_range()
106	if ws and ws.id < range.max then
107		hl.dispatch(hl.dsp.focus({ workspace = ws.id + 1 }))
108	end
109end
110
111-- Go to prev ws, stop at monitor's min
112local function ws_prev()
113	local ws = hl.get_active_workspace()
114	local range = current_range()
115	if ws and ws.id > range.min then
116		hl.dispatch(hl.dsp.focus({ workspace = ws.id - 1 }))
117	end
118end
119
120-- Scroll wheel on desktop (SUPER + scroll)
121hl.bind(mod .. " + mouse_up", function()
122	ws_next()
123end)
124hl.bind(mod .. " + mouse_down", function()
125	ws_prev()
126end)
127
128-- Side mouse buttons (no modifier needed)
129hl.bind("mouse:275", function()
130	ws_prev()
131end) -- back button  → prev
132hl.bind("mouse:276", function()
133	ws_next()
134end) -- forward button → next
135
136-- plugin scrolloverview 
137hl.bind(mod .. " + TAB", function()
138	hl.plugin.scrolloverview.overview("toggle all")
139end)