This commit is contained in:
2026-05-28 01:31:30 -04:00
commit 88a4ce1e05
49 changed files with 1391 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
local utils = require("lua.lib.utils")
local M = {}
function M.is_user_unit_exists(unit)
return utils.command_success("systemctl --user cat " .. utils.shell_quote(unit) .. " >/dev/null 2>&1")
end
M.user_unit_dir = CONFIG_HOME .. "/systemd/user"
function M.ensure_user_unit(unit, source)
if M.is_user_unit_exists(unit) then
return true
end
local target_dir = M.user_unit_dir
local target = target_dir .. "/" .. unit
local cmd = table.concat({
"mkdir -p " .. utils.shell_quote(target_dir),
"ln -s " .. utils.shell_quote(source) .. " " .. utils.shell_quote(target),
"systemctl --user daemon-reload",
}, " && ")
return utils.command_success(cmd)
end
function M.start_user_unit(unit)
return utils.command_success("systemctl --user start " .. utils.shell_quote(unit) .. " >/dev/null 2>&1")
end
return M