all repos — zenUtils @ eb51bc0e91e183f41514c56d383cd8bbf4f9f872

misc utilities for computing zen

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
#!/bin/sh

# logout.sh
# 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

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" = "-p" ]; then
  logoutMenu
fi