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

32 lines
558 B
Bash
Executable file

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