diff --git a/packages/scripts/default.nix b/packages/scripts/default.nix index e1b235b..a7b7ace 100644 --- a/packages/scripts/default.nix +++ b/packages/scripts/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty, imagemagick, swaybg }: +{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty, imagemagick, swaybg, sway, hyprland }: stdenvNoCC.mkDerivation { pname = "scripts"; @@ -12,7 +12,7 @@ stdenvNoCC.mkDerivation { mkdir -p $out/bin cp power-menu.sh $out/bin/power-menu chmod +x $out/bin/power-menu - wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [ libnotify rofi-wayland ]} + wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [ libnotify rofi-wayland sway hyprland ]} cp tmux-sessions.sh $out/bin/tmux-sessions chmod +x $out/bin/tmux-sessions diff --git a/packages/scripts/power-menu.sh b/packages/scripts/power-menu.sh index 5112442..c58dd73 100644 --- a/packages/scripts/power-menu.sh +++ b/packages/scripts/power-menu.sh @@ -2,6 +2,9 @@ set -eu +SWAYSOCK=${SWAYSOCK:-} +HYPRLAND_INSTANCE_SIGNATURE=${HYPRLAND_INSTANCE_SIGNATURE:-} + chpower() { case "$1" in "") @@ -15,13 +18,17 @@ chpower() { Hibernate) exec systemctl hibernate ;; + Logout) + [ -n "$SWAYSOCK" ] && swaymsg exit + [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] && hyprctl dispatch exit + ;; *) notify-send -t 1500 -u low "Invalid Option" ;; esac } -OPTIONS="Shutdown\nReboot\nHibernate" +OPTIONS="Shutdown\nReboot\nHibernate\nLogout" chpower "$(printf "%b" "$OPTIONS" | sort | rofi -dmenu -p "Power Menu")"