Initial commit after confirming working Lua config
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
-- ~/.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")
|
||||
|
||||
for _, ws in ipairs(ws_config) do
|
||||
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)
|
||||
Reference in New Issue
Block a user