power-menu.nix (715B)
1 { pkgs, ... }: 2 3 let 4 power-menu = pkgs.writeShellScriptBin "power-menu" '' 5 choice=$( 6 printf '%s\n' \ 7 'Shut down' \ 8 'Reboot' \ 9 'Reboot to EFI' \ 10 'Exit Hyprland' \ 11 'Turn off screen' | 12 ${pkgs.tofi}/bin/tofi --prompt-text 'Power: ' 13 ) 14 15 case "$choice" in 16 'Shut down') 17 systemctl poweroff 18 ;; 19 20 'Reboot') 21 systemctl reboot 22 ;; 23 24 'Reboot to EFI') 25 systemctl reboot --firmware-setup 26 ;; 27 28 'Exit Hyprland') 29 hyprctl dispatch 'hl.dsp.exit()' 30 ;; 31 32 'Turn off screen') 33 sleep 0.5 34 hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })' 35 ;; 36 esac 37 38 ''; 39 in 40 { 41 environment.systemPackages = [ power-menu ]; 42 }