diff --git a/misc/power-menu.sh b/misc/power-menu.sh new file mode 100755 index 0000000..34f2f6b --- /dev/null +++ b/misc/power-menu.sh @@ -0,0 +1,12 @@ +cmds=('shutdown now' 'reboot' 'hyprlock' 'hyprctl dispatch exit') + +count=${#cmds[@]} +default=15 + +lines=$((count > default ? default : count)) + +a=$(printf ' Shut down\n Reboot\n Lock\n Log out' | fuzzel --dmenu --index --lines $lines --placeholder "Power action: " -I) + +if [ -n "$a" ]; then + ${cmds[a]} +fi diff --git a/modules/wm/hyprland/keybindings.nix b/modules/wm/hyprland/keybindings.nix index fcef0a8..a91699c 100644 --- a/modules/wm/hyprland/keybindings.nix +++ b/modules/wm/hyprland/keybindings.nix @@ -1,6 +1,7 @@ { lib, config, + pkgs, ... }: let inherit (lib) mkIf; @@ -43,6 +44,16 @@ in { params = "pkill waybar || waybar"; } + { + flags = []; + mods = ["SUPER"]; + key = "P"; + dispatcher = "exec"; + params = let + a = pkgs.writeShellScriptBin "power-menu" (builtins.readFile ../../../misc/power-menu.sh); + in "pkill fuzzel || ${a}/bin/power-menu"; + } + { flags = []; mods = ["SUPER"];