49 lines
1.2 KiB
Bash
Executable file
49 lines
1.2 KiB
Bash
Executable file
#!/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
|