awesome: Automatically determine whether systemctl or loginctl should be used in exit_screen

This commit is contained in:
elenapan 2025-07-04 08:43:31 +03:00
parent 02345f2723
commit 5c1a1e8c0b

View file

@ -1,20 +1,22 @@
local awful = require("awful")
local naughty = require("naughty")
local ctl_var = "\"$(command -v systemctl >/dev/null && echo systemctl || echo loginctl)\""
local exit_screen = {}
exit_screen.commands = {
poweroff = function ()
awful.spawn.with_shell("loginctl poweroff")
awful.spawn.with_shell(ctl_var.." poweroff")
end,
reboot = function ()
awful.spawn.with_shell("loginctl reboot")
awful.spawn.with_shell(ctl_var.." reboot")
end,
suspend = function ()
lock_screen_show()
awful.spawn.with_shell("loginctl suspend")
awful.spawn.with_shell(ctl_var.." suspend")
end,
hibernate = function ()
awful.spawn.with_shell("loginctl hibernate")
awful.spawn.with_shell(ctl_var.." hibernate")
end,
exit = function ()
awesome.quit()