-- ~/.config/hypr/workspaces.lua -- Dynamic workspace assignment: replaces kanshi + scripts -- Detects monitor configuration and assigns workspaces accordingly. local function get_monitor_names() local names = {} for _, m in ipairs(hl.get_monitors()) do names[m.name] = true end return names end local function assign_workspaces() local monitors = get_monitor_names() local has_dock = monitors["DP-7"] and monitors["DP-8"] -- Read workspace configurations package.loaded["workspace_config"] = nil -- force reload in case it changed local ws_config = require("workspace_config") -- Iterate in REVERSE to assign the most negative IDs to the first items, counteracting Waybar's low-to-high sorting! for i = #ws_config, 1, -1 do local ws = ws_config[i] local target_mon = has_dock and ws.monitor or "eDP-1" hl.workspace_rule({ workspace = "name:" .. ws.name, monitor = target_mon, persistent = true, default = true }) end end -- Apply on initial load assign_workspaces() -- Re-apply when monitors change hl.on("monitor.added", function(monitor) assign_workspaces() end) hl.on("monitor.removed", function(monitor) assign_workspaces() end)