58 lines
2.0 KiB
Lua
58 lines
2.0 KiB
Lua
local workspace_map = {
|
|
"Home",
|
|
"Dev",
|
|
"Art",
|
|
"Gaming",
|
|
"Writing",
|
|
}
|
|
|
|
local monitor_binds = {}
|
|
|
|
local function setup_monitors()
|
|
-- Clear old binds
|
|
for _, bind in ipairs(monitor_binds) do
|
|
hl.unbind(bind)
|
|
end
|
|
monitor_binds = {}
|
|
|
|
local monitors = hl.get_monitors()
|
|
local monitor_count = #monitors
|
|
|
|
-- Move active window to a workspace with SUPER + SHIFT + [1-5]
|
|
for i = 1, 5 do
|
|
for j = monitor_count, 1, -1 do
|
|
local monitor = monitors[j]
|
|
local workspace_id = "name:" .. workspace_map[i] .. "_" .. j
|
|
hl.notification.create({ text = workspace_id, duration = 2000 })
|
|
hl.workspace_rule({
|
|
workspace = tostring(workspace_id),
|
|
monitor = monitor.name,
|
|
})
|
|
|
|
table.insert(
|
|
monitor_binds,
|
|
hl.bind("SUPER + code:1" .. (i - 1), function()
|
|
hl.dsp.focus({ workspace = workspace_id })
|
|
hl.notification.create({ text = workspace_id, duration = 2000 })
|
|
end, { description = "Switch to workspace " .. workspace_map[i] })
|
|
)
|
|
end
|
|
|
|
table.insert(
|
|
monitor_binds,
|
|
hl.bind("SUPER + SHIFT + code:1" .. (i - 1), function()
|
|
local active_workspace = hl.get_active_workspace()
|
|
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
|
|
hl.notification.create({ text = new_workspace, duration = 2000 })
|
|
hl.dispatch(hl.dsp.window.move({ workspace = new_workspace, follow = false }))
|
|
end, { description = "Move window to workspace " .. workspace_map[i] })
|
|
)
|
|
end
|
|
end
|
|
|
|
hl.on("monitor.added", setup_monitors)
|
|
hl.on("monitor.removed", setup_monitors)
|
|
hl.on("config.reloaded", setup_monitors)
|