-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpower-menu.sh
More file actions
executable file
·33 lines (27 loc) · 848 Bytes
/
power-menu.sh
File metadata and controls
executable file
·33 lines (27 loc) · 848 Bytes
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
#!/usr/bin/env bash
#https://codeberg.org/ersen/bin
usage() {
printf "Usage: %s [OPTION]...
Select and perform actions about power management
-h print this help and exit\n" "$program"
}
die() {
printf "%s\n" "$@"
exit 1
} >&2
program="${0##*"/"}"
actions=( "Logout" "Poweroff" "Reboot" "Suspend" )
while getopts ":h" opt; do
case "$opt" in
"h" ) usage && exit ;;
* ) die "$program: $OPTARG: invalid option" ;;
esac
done
# wofi [-d|--dmenu] [-L|--lines]
selection="$(printf "%s\n" "${actions[@]}" | wofi -dL 4)"
case "$selection" in
"Logout" ) loginctl terminate-user "$USER" ;;
"Poweroff" ) systemctl poweroff ;;
"Reboot" ) systemctl reboot ;;
"Suspend" ) systemctl suspend ;;
esac