zenUtils/logout.sh
2021-03-27 19:47:51 -04:00

60 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# logout.sh
# logout dialogue to be used with a tint2 executor
# no arguments prints the power icon with siji font
# -p runs the prompt in dmenu
# use a sudoers rule with NOPASSWD or a session manager
# copyleft 2020 Derek Stevens <drkste@zoho.com>
# MIT License -- do whatever you want
menu() {
dmenu "$@" -p "action >>>" -fn saucecodepronerdfont-9 -l 6 -nb black -nf grey50 -sb "#1f9b92" -sf black
}
printopts() {
printf "shutdown\nreboot\nsuspend\nhibernate\nlogout"
}
handler() {
case $1 in
shutdown)
poweroff
;;
reboot)
reboot
;;
suspend)
zzz
;;
logout)
if pgrep sddm-helper; then
killall sddm-helper
elif [ "$SESH" = "kwin" ]; then
killall plasmashell
elif [ "$SESH" = "ryudo" ]; then
pkill -9 -P $(pgrep ryudo)
else
killall -0 Xorg
fi
;;
hibernate)
ZZZ
;;
*)
:
esac
}
logoutMenu() {
cmd=$(printopts | menu)
handler $cmd
}
if [ -z $1 ]; then
echo ""
elif [ "$1" = "-p" ]; then
logoutMenu
fi