converted from terminal-based to dmenu-based
This commit is contained in:
parent
fc24a213d9
commit
eb51bc0e91
1 changed files with 34 additions and 38 deletions
72
logout.sh
72
logout.sh
|
@ -1,50 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
# logout.sh
|
||||
# logout dialogue in three parts to be used with a tint2 executor
|
||||
# without arguments displays the power symbol in the executor
|
||||
# -w calls the terminal window with another instance using...
|
||||
# -p to draw and process the prompt
|
||||
# use a sudoers rule with NOPASSWD to bypass password entry when using -p
|
||||
# (c) 2020 Derek Stevens <drkste@zoho.com>
|
||||
# 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
|
||||
|
||||
logoutPrompt() {
|
||||
echo "Power and session controls:"
|
||||
echo "[s] shutdown"
|
||||
echo "[r] reboot"
|
||||
echo "[h] hibernate"
|
||||
echo "[l] logout"
|
||||
read operation
|
||||
case ${operation} in
|
||||
s|S|shutdown|Shutdown|SHUTDOWN)
|
||||
poweroff
|
||||
;;
|
||||
r|R|reboot|Reboot|REBOOT)
|
||||
reboot
|
||||
;;
|
||||
h|H|hibernate|Hibernate|HIBERNATE)
|
||||
zzz
|
||||
;;
|
||||
l|L|logout|Logout|LOGOUT)
|
||||
pkill -9 -P $(pgrep .kwin-session)
|
||||
;;
|
||||
*)
|
||||
clear
|
||||
logoutPromopt
|
||||
;;
|
||||
esac
|
||||
menu() {
|
||||
dmenu "$@" -p "action >>>" -fn lucidatypewriter-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)
|
||||
pkill -9 -P $(pgrep .kwin-session);;
|
||||
hibernate)
|
||||
ZZZ;;
|
||||
*)
|
||||
:
|
||||
esac
|
||||
}
|
||||
|
||||
logoutMenu() {
|
||||
printopts | menu | handler
|
||||
}
|
||||
|
||||
if [ -z $1 ]; then
|
||||
echo ""
|
||||
|
||||
elif [ "$1" = "-w" ]; then
|
||||
|
||||
if ! wmctrl -l | grep "Session Control"; then
|
||||
exec alacritty -d 30 5 --position 9999 0 -t "Session Control" -e sudo ${HOME}/src/zenUtils/logout.sh -p &
|
||||
fi
|
||||
|
||||
elif [ "$1" = "-p" ]; then
|
||||
logoutPrompt
|
||||
logoutMenu
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue