mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-29 03:37:13 +08:00
power: Automatically determine whether systemctl or loginctl should be used
This commit is contained in:
parent
ba4b40cb2a
commit
21c2379bbe
2 changed files with 15 additions and 5 deletions
|
|
@ -9,22 +9,28 @@ fi
|
|||
|
||||
action=$1
|
||||
|
||||
if command -v systemctl >/dev/null; then
|
||||
ctl=systemctl
|
||||
else
|
||||
ctl=loginctl
|
||||
fi
|
||||
|
||||
poweroff() {
|
||||
loginctl poweroff
|
||||
"$ctl" poweroff
|
||||
}
|
||||
|
||||
reboot() {
|
||||
loginctl reboot
|
||||
"$ctl" reboot
|
||||
}
|
||||
|
||||
suspend() {
|
||||
"${eww}/manage" hide powermenu
|
||||
loginctl suspend
|
||||
"$ctl" suspend
|
||||
}
|
||||
|
||||
hibernate() {
|
||||
"${eww}/manage" hide powermenu
|
||||
loginctl hibernate
|
||||
"$ctl" hibernate
|
||||
}
|
||||
|
||||
exit() {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,11 @@ notify() {
|
|||
wait_countdown_suspend() {
|
||||
if ! zenity --icon-name battery-empty --question --timeout=10 --text="Keep machine on?\n\nIt will suspend if no answer is given in 10 seconds"; then
|
||||
notify-send.sh -s "$(</tmp/countdown-notifications-file)"
|
||||
loginctl suspend
|
||||
if command -v systemctl >/dev/null; then
|
||||
systemctl suspend
|
||||
else
|
||||
loginctl suspend
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue