59 lines
1.1 KiB
Bash
Executable file
59 lines
1.1 KiB
Bash
Executable file
# shellcheck disable=SC2148
|
|
|
|
confirm() {
|
|
rofi -dmenu \
|
|
-i \
|
|
-no-fixed-num-lines \
|
|
-p "Are you sure? [y/n]: " \
|
|
-theme power
|
|
}
|
|
|
|
# Options
|
|
shutdown="" # Icon: power
|
|
reboot="" # Icon: restart
|
|
lock="" # Icon: lock
|
|
hibernate="" # Icon: power_sleep
|
|
exit_wm="" # Icon: exit_to_app
|
|
#shutdown="S"
|
|
#reboot="R"
|
|
#lock="L"
|
|
#hibernate="S"
|
|
#exit_wm="E"
|
|
|
|
# Variable passed to rofi
|
|
options="${shutdown}\n${reboot}\n${lock}\n${hibernate}\n${exit_wm}"
|
|
uptime=$(uptime | awk '{print $1}' || true)
|
|
lockcmd="swaylock --ignore-empty-password --daemonize --show-failed-attempts --indicator-caps-lock --image {WALLPAPER} --scaling fill"
|
|
|
|
chosen="$(echo -e "${options}" | rofi -theme power -p "Uptime: ${uptime}" -dmenu -selected-row 2)"
|
|
|
|
if [[ ${chosen} == "" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [[ ${chosen} == "${lock}" ]]; then
|
|
${lockcmd}
|
|
exit 0
|
|
fi
|
|
|
|
answer=$(confirm)
|
|
|
|
if [[ ${answer} == "y" ]]; then
|
|
case "${chosen}" in
|
|
"${shutdown}")
|
|
systemctl poweroff
|
|
;;
|
|
"${reboot}")
|
|
systemctl reboot
|
|
;;
|
|
"${hibernate}")
|
|
${lockcmd}
|
|
systemctl hibernate
|
|
;;
|
|
"${exit_wm}")
|
|
riverctl exit
|
|
;;
|
|
*) ;;
|
|
|
|
esac
|
|
fi
|