stow_dotfiles/scripts/.local/bin/rofi-logout
Matthieu Fortin (CPC/CCP) 16fe321283 This is not a commit
2024-11-19 10:45:01 -05:00

60 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
THEME=${1:-logout}
question=$(echo "󰌾 lock|󰍃 logout|󰜉 reboot|󰐥 shutdown" | rofi -sep "|" \
-dmenu -i -p 'System: ' "" \
-hide-scrollbar \
-eh 1 \
-color-enabled true \
-theme "$THEME")
case $question in
*lock)
# use lowercase only
case "${XDG_CURRENT_DESKTOP,,}" in
hyprland)
hyprctl dispatch exit
;;
*)
if [ "$(pgrep -x lightdm)" ] && [ "$(command -v light-locker)" ]; then
light-locker-command -l
fi
;;
esac
;;
*logout)
case "${XDG_CURRENT_DESKTOP,,}" in
hyprland)
hyprctl dispatch exit
;;
openbox)
openbox --exit
;;
i3)
i3-msg exit
;;
qtile)
qtile cmd-obj -o cmd -f shutdown
;;
esac
;;
*reboot)
if [[ $(command -v systemctl) ]]; then
systemctl reboot
else
shutdown -r now
fi
;;
*shutdown)
if [[ $(command -v systemctl) ]]; then
systemctl poweroff
else
poweroff
fi
;;
*)
exit 0 # do nothing on wrong response
;;
esac