From 90dc52b6c513426113e3fd44b0b7bc0ec87e917e Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Sun, 20 Nov 2022 16:48:43 +0100 Subject: [PATCH] rofi:powermenu: Support systems with full systemd When systemd is fully installed, `loginctl` does not support the actions `reboot`, `poweroff` and `suspend`. Fix this by using `systemctl` if installed. --- .config/rofi/powermenu.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.config/rofi/powermenu.sh b/.config/rofi/powermenu.sh index 58d75f4..b71537b 100755 --- a/.config/rofi/powermenu.sh +++ b/.config/rofi/powermenu.sh @@ -2,14 +2,21 @@ # Inspired by: # https://github.com/cramermarius/rofi-menus/blob/master/scripts/powermenu.sh +# Make this script work on systems with and without full systemd (e.g. elogind) +if command -v systemctl &>/dev/null; then + controller=systemctl +else + controller=loginctl +fi + # entries with associated commands declare -A entries entries=( [lock]="xset s activate" [logout]="i3-msg exit" - [reboot]="loginctl reboot" - [shutdown]="loginctl poweroff" - [suspend]="loginctl suspend" + [reboot]="$controller reboot" + [shutdown]="$controller poweroff" + [suspend]="$controller suspend" [suspend (scheduled)]="scheduled_suspend" )