From d1f1546a0daff6fe1793abc204df9b062426cd13 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sun, 11 Oct 2020 01:58:58 -0400 Subject: [PATCH] simple logout script for the kwin+tint2+xfdesktop session --- logout.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 logout.sh diff --git a/logout.sh b/logout.sh new file mode 100755 index 0000000..ab349c1 --- /dev/null +++ b/logout.sh @@ -0,0 +1,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 +# 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