diff --git a/logout.sh b/logout.sh index 4717e94..3200635 100755 --- a/logout.sh +++ b/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 +# 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 # 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