aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/powermenu
blob: 0a26582b1d43d346d8012bc5a01690175ca9e34b (plain)
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
#!/usr/bin/env bash

UPTIME=$(uptime -p | sed -e 's/up //g')
DWM_PID="$(pidof dwm)"

OPTION_CANCEL="Cancel"
OPTION_SHUTDOWN="Shutdown"
OPTION_REBOOT="Restart"
OPTION_LOGOUT="Logout"
OPTION_LOCK="Lock"

OPTIONS="$OPTION_CANCEL\n$OPTION_SHUTDOWN\n$OPTION_REBOOT\n$OPTION_LOCK\n$OPTION_LOGOUT"
SELECTED="$(echo -e "$OPTIONS" | dmenu -i -l 5 -p "Uptime: $UPTIME" -z 700 -h 30 -y 900 -x 1090 -fn 'JetBrains Mono:size=19')"

case $SELECTED in
	$OPTION_SHUTDOWN)
		sudo systemctl poweroff
		;;
	$OPTION_REBOOT)
		sudo systemctl reboot
		;;
	$OPTION_LOCK)
		slock
		;;
	$OPTION_LOGOUT)
		kill -TERM $DWM_PID
    ;;
esac