configuration.nix/packages/scripts/misc/power-menu.sh

33 lines
558 B
Bash
Raw Normal View History

2023-04-06 01:27:09 +05:30
#!/bin/sh
set -eu
2023-04-08 02:49:06 +05:30
HYPRLAND_INSTANCE_SIGNATURE=${HYPRLAND_INSTANCE_SIGNATURE:-}
2023-04-06 01:27:09 +05:30
chpower() {
case "$1" in
"")
;;
Shutdown)
exec systemctl poweroff
;;
Reboot)
exec systemctl reboot
;;
Hibernate)
exec systemctl hibernate
;;
2023-04-08 02:49:06 +05:30
Logout)
[ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] && hyprctl dispatch exit
;;
2023-04-06 01:27:09 +05:30
*)
notify-send -t 1500 -u low "Invalid Option"
;;
esac
}
2023-04-08 02:49:06 +05:30
OPTIONS="Shutdown\nReboot\nHibernate\nLogout"
2023-04-06 01:27:09 +05:30
2023-04-06 01:33:37 +05:30
chpower "$(printf "%b" "$OPTIONS" | sort | rofi -dmenu -p "Power Menu")"
2023-04-06 01:27:09 +05:30