2022-11-19 20:00:54 +01:00
|
|
|
# shellcheck disable=SC2148
|
2022-11-11 11:54:21 +01:00
|
|
|
|
|
|
|
confirm() {
|
2022-11-19 20:00:54 +01:00
|
|
|
rofi -dmenu \
|
|
|
|
-i \
|
|
|
|
-no-fixed-num-lines \
|
|
|
|
-p "Are you sure? [y/n]: " \
|
|
|
|
-theme power
|
2022-11-11 11:54:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Options
|
|
|
|
shutdown=""
|
|
|
|
reboot=""
|
|
|
|
lock=""
|
|
|
|
hibernate=""
|
|
|
|
exit_wm=""
|
|
|
|
|
|
|
|
# Variable passed to rofi
|
|
|
|
options="${shutdown}\n${reboot}\n${lock}\n${hibernate}\n${exit_wm}"
|
|
|
|
uptime=$(uptime | awk '{print $1}' || true)
|
2022-12-01 10:17:03 +01:00
|
|
|
lockcmd="i3lock-color --image /home/erwin/.wallpapers/river-3840.png --color=333333ff --tiling --ignore-empty-password --show-failed-attempts --screen=0 --clock --pass-volume-keys"
|
2022-11-11 11:54:21 +01:00
|
|
|
|
|
|
|
chosen="$(echo -e "${options}" | rofi -theme power -p "Uptime: ${uptime}" -dmenu -selected-row 2)"
|
|
|
|
|
2022-11-19 20:00:54 +01:00
|
|
|
if [[ ${chosen} == "" ]]; then
|
|
|
|
exit 0
|
2022-11-11 11:54:21 +01:00
|
|
|
fi
|
|
|
|
|
2022-11-19 20:00:54 +01:00
|
|
|
if [[ ${chosen} == "${lock}" ]]; then
|
|
|
|
${lockcmd}
|
|
|
|
exit 0
|
2022-11-11 11:54:21 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
answer=$(confirm)
|
|
|
|
|
2022-11-19 20:00:54 +01:00
|
|
|
if [[ ${answer} == "y" ]]; then
|
|
|
|
case "${chosen}" in
|
|
|
|
"${shutdown}")
|
|
|
|
systemctl poweroff
|
|
|
|
;;
|
|
|
|
"${reboot}")
|
|
|
|
systemctl reboot
|
|
|
|
;;
|
|
|
|
"${hibernate}")
|
|
|
|
${lockcmd}
|
|
|
|
systemctl hibernate
|
|
|
|
;;
|
|
|
|
"${exit_wm}")
|
|
|
|
i3-msg exit
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
|
|
|
|
esac
|
2022-11-11 11:54:21 +01:00
|
|
|
fi
|