2024-01-22 06:28:52 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
styles="$(dirname $(which $0))/../styles"
|
|
|
|
rofi_command="rofi -theme $styles/powermenu.rasi"
|
|
|
|
|
|
|
|
#### Options ###
|
|
|
|
shutdown=""
|
|
|
|
reboot=""
|
|
|
|
lock=""
|
|
|
|
suspend=""
|
|
|
|
logout=""
|
|
|
|
|
|
|
|
options="$shutdown\n$reboot\n$lock\n$suspend\n$logout"
|
|
|
|
|
|
|
|
uptime=$(uptime | sed -e 's/up //g')
|
|
|
|
|
|
|
|
confirm_exit() {
|
|
|
|
"$(dirname $(which $0))/confirm.sh"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Message
|
|
|
|
msg() {
|
|
|
|
rofi -theme "$styles/message.rasi" -e "Available Options - yes / y / no / n"
|
|
|
|
}
|
|
|
|
|
|
|
|
chosen="$(echo -e "$options" | $rofi_command -p " $uptime " -dmenu -selected-row 2)"
|
|
|
|
case $chosen in
|
|
|
|
$lock)
|
2024-01-23 16:16:54 -06:00
|
|
|
swaylock
|
2024-01-22 06:28:52 -06:00
|
|
|
;;
|
|
|
|
$shutdown)
|
|
|
|
ans=$(confirm_exit &)
|
|
|
|
if [[ $ans == "yes" ]]; then
|
|
|
|
systemctl poweroff
|
|
|
|
elif [[ $ans == "no" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
msg
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
$reboot)
|
|
|
|
ans=$(confirm_exit &)
|
|
|
|
if [[ $ans == "yes" ]]; then
|
|
|
|
systemctl reboot
|
|
|
|
elif [[ $ans == "no" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
msg
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
$suspend)
|
|
|
|
ans=$(confirm_exit &)
|
|
|
|
if [[ $ans == "yes" ]]; then
|
2024-01-23 16:16:54 -06:00
|
|
|
# amixer set Master mute
|
2024-01-22 06:28:52 -06:00
|
|
|
systemctl suspend
|
|
|
|
elif [[ $ans == "no" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
msg
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
$logout)
|
|
|
|
ans=$(confirm_exit &)
|
|
|
|
if [[ $ans == "yes" || $ans == "y" ]]; then
|
|
|
|
loginctl terminate-session ${XDG_SESSION_ID-}
|
|
|
|
elif [[ $ans == "no" || $ans == "n" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
msg
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|