logout.sh (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
#!/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> # 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 } if [ -z $1 ]; then echo "" elif [ "$1" = "-w" ]; then if ! wmctrl -l | grep "Session Control"; then exec alacritty -d 30 5 -t "Session Control" -e sudo ${HOME}/src/zenUtils/logout.sh -p & fi elif [ "$1" = "-p" ]; then logoutPrompt fi |