aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sh/.local/bin/powermenu
blob: 0166eeec337465265ee180b99a01664414839197 (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
29
30
31
32
33
#!/bin/sh

if [ ! -t 0 ]; then
	set -- "$(awk '{print tolower($2)}')"
elif [ $# -eq 0 ]; then
	printf '%s\n' '󰌾 Lock' '󰍃 Logout' '⏾ Suspend' '󰋊 Hibernate' '󰜉 Reboot' '󰐥 Poweroff'
	exit 0
fi

case "$1" in
lock)
	loginctl lock-session "${XDG_SESSION_ID-}"
	;;
logout)
	loginctl terminate-session "${XDG_SESSION_ID-}"
	;;
suspend)
	systemctl suspend
	;;
hibernate)
	systemctl hibernate
	;;
reboot)
	systemctl reboot
	;;
poweroff)
	systemctl poweroff
	;;
*)
	echo "Invalid argument: $*"
	exit 1
	;;
esac