powermenu: Adapt for both archlinux and voidlinux
Keeps using the known systemctl commands for voidlinux environments (or other environments that have access to the `systemctl` command). For voidlinux it instead uses the commands `poweroff`, `reboot`, `zzz` and `ZZZ` (which are the same script). Works fairly naively for now and does no checking if the commands exist or work. Runs required commands as sudo so ideally the user or group has access to a passwordless implementation of the commands.
This commit is contained in:
parent
0cbd8d548f
commit
b0ab5c59dd
1 changed files with 20 additions and 4 deletions
|
@ -58,12 +58,20 @@ result=$(printf "%s" "$menu" | $selector_program $selector_opts --prompt "$promp
|
|||
case "$result" in
|
||||
"Shutdown" | "$power_off_btn")
|
||||
if [ -n "$POWERMENU_SHUTDOWN_CMD" ]; then eval "$POWERMENU_SHUTDOWN_CMD"; else
|
||||
systemctl poweroff
|
||||
if [ -x /usr/bin/systemctl ]; then
|
||||
systemctl poweroff
|
||||
else
|
||||
sudo poweroff
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
"Reboot" | "$reboot_btn")
|
||||
if [ -n "$POWERMENU_REBOOT_CMD" ]; then eval "$POWERMENU_REBOOT_CMD"; else
|
||||
systemctl reboot
|
||||
if [ -x /usr/bin/systemctl ]; then
|
||||
systemctl reboot
|
||||
else
|
||||
sudo reboot
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
"Lockscreen" | "$lock_btn")
|
||||
|
@ -81,12 +89,20 @@ case "$result" in
|
|||
;;
|
||||
"Suspend" | "$suspend_btn")
|
||||
if [ -n "$POWERMENU_SUSPEND_CMD" ]; then eval "$POWERMENU_SUSPEND_CMD"; else
|
||||
systemctl suspend-then-hibernate
|
||||
if [ -x /usr/bin/systemctl ]; then
|
||||
systemctl suspend-then-hibernate
|
||||
else
|
||||
sudo zzz -H
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
"Hibernate" | "$hibernate_btn")
|
||||
if [ -n "$POWERMENU_HIBERNATE_CMD" ]; then eval "$POWERMENU_HIBERNATE_CMD"; else
|
||||
systemctl hibernate
|
||||
if [ -x /usr/bin/systemctl ]; then
|
||||
systemctl hibernate
|
||||
else
|
||||
sudo ZZZ
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue