local settings = require("lua.lib.settings") require("lua.lib.globals") local utils = require("lua.lib.utils") local events = require("lua.lib.events") local bind = require("lua.lib.bind") local M = {} local modules = {} local function is_module_exists(name) return utils.is_file_exists(HYPR .. "/lua/modules/" .. name .. ".lua") end local function load_module(name) if not is_module_exists(name) then return {} end local default_mod = require("lua.modules." .. name) local user_modname = "lua.user.modules." .. name local mod = utils.extend_config(default_mod, user_modname) return mod end for name, enabled in pairs(settings.modules) do if enabled then local mod = load_module(name) print("module " .. name .. " loaded.") table.insert(modules, { name = name, config = mod, }) end end M.autostart = {} M.autostop = {} M.binds = {} local function collect_modules_prop(module, prop) if module[prop] then M[prop] = utils.list_extend(M[prop], module[prop]) end end for _, item in ipairs(modules) do local module = item.config collect_modules_prop(module, "autostart") collect_modules_prop(module, "autostop") collect_modules_prop(module, "binds") end function M.load() events.map("hyprland.start", M.autostart) events.map("hyprland.shutdown", M.autostop) bind.map(M.binds) end return M