From b72c2a344d01c136d3ffffe6010a638f0d4224ce Mon Sep 17 00:00:00 2001 From: Nydragon Date: Tue, 31 Dec 2024 01:00:57 +0100 Subject: [PATCH] feat: add powermenu using configured dmenu tool --- home/scripts/default.nix | 14 +++++++++++++- home/sway/default.nix | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/home/scripts/default.nix b/home/scripts/default.nix index 6b5e207..6815637 100644 --- a/home/scripts/default.nix +++ b/home/scripts/default.nix @@ -5,8 +5,9 @@ ... }: let - inherit (pkgs.writers) writeFishBin; + inherit (pkgs.writers) writeFishBin writeBashBin; inherit (lib.my) getExe; + runner = config.modules.system.roles.desktop.runner; nixos-rebuild = name: word: writeFishBin name '' @@ -111,4 +112,15 @@ in --use-remote-sudo &| ${getExe pkgs.nix-output-monitor} ''; + powerMenu = writeBashBin "power-menu" '' + case "$(echo -e "Shutdown\nRestart\nHibernate\nLogout\nSuspend\nLock" | ${runner.dmenu} )" in + Shutdown) exec systemctl poweroff ;; + Restart) exec systemctl reboot ;; + Logout) exec loginctl terminate-session "$${XDG_SESSION_ID-}" ;; + Hibernate) exec systemctl hibernate ;; + Suspend) exec systemctl suspend ;; + Lock) exec loginctl lock-session "$${XDG_SESSION_ID-}" ;; + esac + ''; + } diff --git a/home/sway/default.nix b/home/sway/default.nix index 26af166..209b41e 100644 --- a/home/sway/default.nix +++ b/home/sway/default.nix @@ -63,7 +63,7 @@ lib.mkIf osConfig.programs.sway.enable { lib.mkOptionDefault { "${mod}+p" = "exec ${getExe pkgs.hyprlock}"; - "${mod}+Shift+p" = "exec ${getExe pkgs.rofi} -show p -modi p:${getExe pkgs.rofi-power-menu}"; + "${mod}+Shift+p" = "exec ${getExe pkgs.scripts.powerMenu}"; # Reload the config file "${mod}+Shift+c" = "reload"; # Kill the focused window