init
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
local settings = require("lua.lib.settings")
|
||||
require("lua.lib.globals")
|
||||
local utils = require("lua.lib.utils")
|
||||
local events = require("lua.lib.events")
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
for _, bind in pairs(M.binds) do
|
||||
bind()
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,36 @@
|
||||
local settings = require("lua.lib.settings")
|
||||
local systemd = require("lua.lib.systemd")
|
||||
local utils = require("lua.lib.utils")
|
||||
require("lua.lib.globals")
|
||||
local M = {}
|
||||
|
||||
local function start_swaync()
|
||||
if settings["systemd"] then
|
||||
local unit = "swaync.service"
|
||||
local source = CONFIG_HOME .. "hypr/systemd/" .. unit
|
||||
|
||||
if systemd.ensure_user_unit(unit, source) then
|
||||
hl.exec_cmd("systemctl --user start swaync")
|
||||
else
|
||||
hl.exec_cmd("swaync")
|
||||
end
|
||||
else
|
||||
hl.exec_cmd("swaync")
|
||||
end
|
||||
end
|
||||
|
||||
local function stop_swaync()
|
||||
if settings["systemd"] and utils.command_success("systemctl --user status swaync") then
|
||||
hl.exec_cmd("systemctl --user stop swaync")
|
||||
end
|
||||
end
|
||||
|
||||
M.autostart = {
|
||||
start_swaync,
|
||||
}
|
||||
|
||||
M.autostop = {
|
||||
stop_swaync,
|
||||
}
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,19 @@
|
||||
local M = {}
|
||||
local bind = require("lua.lib.bind")
|
||||
|
||||
local function start_waybar()
|
||||
hl.exec_cmd("~/dotfiles/waybar/launch.sh")
|
||||
end
|
||||
|
||||
M.autostart = {
|
||||
start_waybar,
|
||||
}
|
||||
|
||||
M.binds = {
|
||||
function()
|
||||
bind.leader_key("SHIFT + B", hl.dsp.exec_cmd("~/dotfiles/waybar/launch.sh"), "(re)launch waybar", {})
|
||||
bind.leader_key("CTRL + B", hl.dsp.exec_cmd("~/dotfiles/waybar/toggle.sh"), "toggle waybar", {})
|
||||
end,
|
||||
}
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user