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.
This commit is contained in:
@@ -2,14 +2,21 @@
|
|||||||
# Inspired by:
|
# Inspired by:
|
||||||
# https://github.com/cramermarius/rofi-menus/blob/master/scripts/powermenu.sh
|
# 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
|
# entries with associated commands
|
||||||
declare -A entries
|
declare -A entries
|
||||||
entries=(
|
entries=(
|
||||||
[lock]="xset s activate"
|
[lock]="xset s activate"
|
||||||
[logout]="i3-msg exit"
|
[logout]="i3-msg exit"
|
||||||
[reboot]="loginctl reboot"
|
[reboot]="$controller reboot"
|
||||||
[shutdown]="loginctl poweroff"
|
[shutdown]="$controller poweroff"
|
||||||
[suspend]="loginctl suspend"
|
[suspend]="$controller suspend"
|
||||||
[suspend (scheduled)]="scheduled_suspend"
|
[suspend (scheduled)]="scheduled_suspend"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user