This commit is contained in:
2019-01-22 23:43:52 +01:00
parent 4d731c3564
commit a2f54f465e
7 changed files with 251 additions and 6 deletions

47
bin/power-menu Executable file
View File

@@ -0,0 +1,47 @@
#!/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