-
Notifications
You must be signed in to change notification settings - Fork 11
/
rofi-power
executable file
·46 lines (40 loc) · 1.02 KB
/
rofi-power
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
#!/usr/bin/env bash
# rofi-power
# Use rofi to call systemctl for shutdown, reboot, etc
# 2016 Oliver Kraitschy - http://okraits.de
OPTIONS="Reboot system\nPower-off system\nSuspend system\nHibernate system"
# source configuration or use default values
if [ -f $HOME/.config/rofi-power/config ]; then
source $HOME/.config/rofi-power/config
else
LAUNCHER="rofi -width 30 -dmenu -i -p rofi-power"
USE_LOCKER="false"
LOCKER="i3lock"
fi
# Show exit wm option if exit command is provided as an argument
if [ ${#1} -gt 0 ]; then
OPTIONS="Exit window manager\n$OPTIONS"
fi
option=`echo -e $OPTIONS | $LAUNCHER | awk '{print $1}' | tr -d '\r\n'`
if [ ${#option} -gt 0 ]
then
case $option in
Exit)
eval $1
;;
Reboot)
systemctl reboot
;;
Power-off)
systemctl poweroff
;;
Suspend)
$($USE_LOCKER) && "$LOCKER"; systemctl suspend
;;
Hibernate)
$($USE_LOCKER) && "$LOCKER"; systemctl hibernate
;;
*)
;;
esac
fi