diff --git a/dotfiles/config/hypr/hyprland.lua b/dotfiles/config/hypr/hyprland.lua index 5c67c23e..d3ab53df 100644 --- a/dotfiles/config/hypr/hyprland.lua +++ b/dotfiles/config/hypr/hyprland.lua @@ -19,16 +19,61 @@ package.path = table.concat({ package.path, }, ";") -local modules = { - "hyprland.state", - "hyprland.scratchpads", - "hyprland.core", - "hyprland.layouts", - "hyprland.windows", - "hyprland.settings", - "hyprland.binds", - "hyprland.events", -} +local function shell_quote(value) + return "'" .. tostring(value):gsub("'", "'\\''") .. "'" +end + +local function module_load_phase(name) + if name == "state" then + return 0 + elseif name == "binds" then + return 20 + elseif name == "events" then + return 30 + end + + return 10 +end + +local function discover_modules() + local modules_dir = base_dir .. "/hyprland" + local handle = assert(io.popen("find " .. shell_quote(modules_dir) .. " -maxdepth 1 -type f -name '*.lua' -print")) + local discovered = {} + + for path in handle:lines() do + local name = path:match("/([^/]+)%.lua$") + if name then + discovered[#discovered + 1] = { + name = name, + module = "hyprland." .. name, + phase = module_load_phase(name), + } + end + end + + handle:close() + + table.sort(discovered, function(left, right) + if left.phase ~= right.phase then + return left.phase < right.phase + end + + return left.name < right.name + end) + + local modules = {} + for _, item in ipairs(discovered) do + modules[#modules + 1] = item.module + end + + if modules[1] ~= "hyprland.state" then + error("hyprland/state.lua is required") + end + + return modules +end + +local modules = discover_modules() for _, module in ipairs(modules) do package.loaded[module] = nil diff --git a/dotfiles/config/hypr/monitors.conf b/dotfiles/config/hypr/monitors.conf deleted file mode 100644 index e69de29b..00000000 diff --git a/dotfiles/config/hypr/workspaces.conf b/dotfiles/config/hypr/workspaces.conf deleted file mode 100644 index e69de29b..00000000