2026-06-08 18:28:10 +01:00
|
|
|
local workspace_map = {
|
|
|
|
|
"Home",
|
|
|
|
|
"Dev",
|
|
|
|
|
"Art",
|
|
|
|
|
"Gaming",
|
|
|
|
|
"Writing",
|
|
|
|
|
}
|
2026-06-07 19:03:11 +01:00
|
|
|
|
2026-06-27 17:04:05 +01:00
|
|
|
local function setup_monitors()
|
|
|
|
|
local monitors = hl.get_monitors()
|
|
|
|
|
local monitor_count = #monitors
|
2026-06-27 12:51:49 +01:00
|
|
|
|
2026-06-27 17:04:05 +01:00
|
|
|
-- Move active window to a workspace with SUPER + SHIFT + [1-5]
|
2026-06-28 22:45:03 +01:00
|
|
|
for i = 1, #workspace_map do
|
2026-06-27 17:04:05 +01:00
|
|
|
for j = monitor_count, 1, -1 do
|
|
|
|
|
local monitor = monitors[j]
|
2026-06-27 19:38:20 +01:00
|
|
|
-- local workspace_id = "name:" .. workspace_map[i] .. "_" .. j
|
|
|
|
|
local workspace_id = (i - 1) * monitor_count + j
|
|
|
|
|
local workspace_name = workspace_map[i] .. "_" .. j
|
2026-06-27 17:04:05 +01:00
|
|
|
hl.workspace_rule({
|
2026-06-28 22:45:03 +01:00
|
|
|
workspace = "name:" .. workspace_name,
|
|
|
|
|
-- default_name = workspace_name,
|
2026-06-27 17:04:05 +01:00
|
|
|
monitor = monitor.name,
|
2026-06-27 19:38:20 +01:00
|
|
|
default = i == 1,
|
2026-06-27 17:04:05 +01:00
|
|
|
})
|
|
|
|
|
|
2026-06-28 20:26:30 +01:00
|
|
|
hl.bind(
|
|
|
|
|
"SUPER + code:1" .. (i - 1),
|
|
|
|
|
hl.dsp.focus({ workspace = "name:" .. workspace_name }),
|
|
|
|
|
{ description = "Switch to workspace " .. workspace_map[i] }
|
2026-06-27 17:04:05 +01:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
2026-06-28 20:26:30 +01:00
|
|
|
hl.bind("SUPER + SHIFT + code:1" .. (i - 1), function()
|
2026-06-28 22:45:03 +01:00
|
|
|
local active_window = hl.get_active_window()
|
|
|
|
|
local active_workspace = active_window.workspace
|
2026-06-28 20:26:30 +01:00
|
|
|
local active_workspace_name = active_workspace.name
|
|
|
|
|
local monitor_suffix = active_workspace_name:match("_(%d+)$") or "1"
|
|
|
|
|
local new_workspace = "name:" .. workspace_map[i] .. "_" .. monitor_suffix
|
|
|
|
|
-- local new_workspace = (i - 1) * monitor_count + active_workspace.id
|
2026-06-28 22:45:03 +01:00
|
|
|
hl.dispatch(hl.dsp.window.move({ workspace = new_workspace, window = active_window, follow = false }))
|
2026-06-28 20:26:30 +01:00
|
|
|
end, { description = "Move window to workspace " .. workspace_map[i] })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- A hack to move to the Home workspace when Hyprland first loads
|
2026-06-28 22:45:03 +01:00
|
|
|
for j = monitor_count, 1, -1 do
|
|
|
|
|
if hl.get_workspaces()[j].id > 0 and monitor_count == 2 then
|
|
|
|
|
hl.dispatch(hl.dsp.focus({ workspace = "name:Home_" .. j }))
|
2026-06-28 20:26:30 +01:00
|
|
|
end
|
2026-06-27 12:51:49 +01:00
|
|
|
end
|
2026-06-07 19:32:56 +01:00
|
|
|
end
|
2026-06-27 17:04:05 +01:00
|
|
|
|
|
|
|
|
hl.on("monitor.added", setup_monitors)
|
|
|
|
|
hl.on("monitor.removed", setup_monitors)
|
|
|
|
|
hl.on("config.reloaded", setup_monitors)
|