wm-logs/home/local/bin/scripts/rofi_powermenu.sh

59 lines
882 B
Bash
Raw Normal View History

2023-07-06 19:44:39 +08:00
#!/bin/bash
prompt="Select the action..."
2023-07-06 19:44:39 +08:00
mesg="Uptime : `uptime -p | sed -e 's/up //g'`"
2023-07-10 13:44:24 +08:00
option_1=""
2023-07-06 19:44:39 +08:00
option_2=""
2023-07-10 13:44:24 +08:00
option_3=""
2023-07-06 19:44:39 +08:00
option_4=""
2023-07-10 13:44:24 +08:00
option_5=""
2023-07-06 19:44:39 +08:00
yes=''
no=''
rofi_powermenu() {
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5" | rofi -dmenu -p "$prompt" -mesg "$mesg" -markup-rows -theme powermenu
}
confirm_run () {
2023-07-10 10:48:18 +08:00
selected="$(~/.local/bin/scripts/rofi_confirm.sh)"
2023-07-06 19:44:39 +08:00
if [[ "$selected" == "$yes" ]]; then
${1}
else
exit
fi
}
xlock () {
2023-07-10 10:48:18 +08:00
~/.local/bin/scripts/xlock.sh --lock
}
2023-07-10 10:48:18 +08:00
hibernate () {
xlock
systemctl hibernate
}
2023-07-06 19:44:39 +08:00
chosen="$(rofi_powermenu)"
case ${chosen} in
$option_1)
xlock
2023-07-06 19:44:39 +08:00
;;
$option_2)
confirm_run 'bspc quit'
;;
$option_3)
2023-07-10 10:48:18 +08:00
confirm_run 'hibernate'
2023-07-06 19:44:39 +08:00
;;
$option_4)
confirm_run 'systemctl reboot'
;;
$option_5)
2023-07-07 19:57:20 +08:00
confirm_run 'systemctl poweroff'
2023-07-06 19:44:39 +08:00
;;
2023-07-07 19:57:20 +08:00
esac