2023-07-06 19:44:39 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-07-07 15:31:10 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-07-07 15:31:10 +08:00
|
|
|
xlock () {
|
2023-07-14 15:05:49 +08:00
|
|
|
~/.local/bin/scripts/xlock.sh
|
2023-07-07 15:31:10 +08:00
|
|
|
}
|
|
|
|
|
2023-07-10 10:48:18 +08:00
|
|
|
hibernate () {
|
2023-07-14 15:05:49 +08:00
|
|
|
mpc pause
|
2023-07-10 10:48:18 +08:00
|
|
|
systemctl hibernate
|
|
|
|
}
|
2023-07-06 19:44:39 +08:00
|
|
|
|
|
|
|
chosen="$(rofi_powermenu)"
|
|
|
|
|
|
|
|
case ${chosen} in
|
|
|
|
$option_1)
|
2023-07-07 15:31:10 +08:00
|
|
|
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
|