zenUtils/logout.sh

59 lines
984 B
Bash
Raw Normal View History

#!/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() {
2021-11-27 05:50:27 +00:00
printf "shutdown\nreboot\nsuspend\nlogout"
}
handler() {
case $1 in
shutdown)
poweroff
;;
reboot)
reboot
;;
suspend)
zzz
;;
logout)
2021-03-27 23:47:51 +00:00
if pgrep sddm-helper; then
killall sddm-helper
2021-07-13 21:12:26 +00:00
elif pgrep ryudo; then
2021-11-27 05:50:27 +00:00
killall ryudo
2021-03-27 23:47:51 +00:00
else
2022-01-14 04:57:24 +00:00
killall fluxbox
2021-03-27 23:47:51 +00:00
fi
;;
hibernate)
ZZZ
;;
*)
:
esac
}
logoutMenu() {
cmd=$(printopts | menu)
handler $cmd
}
if [ -z $1 ]; then
echo ""
elif [ "$1" = "-p" ]; then
logoutMenu
fi