From 0a2131cb75dd960161e7036322d5f38ef5ddc821 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Thu, 29 Aug 2024 18:55:55 -0400 Subject: [PATCH] swayidle: setup binPath --- homeManagerModules/services/mako/default.nix | 2 +- .../services/swayidle/default.nix | 44 +++++++++++++------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/homeManagerModules/services/mako/default.nix b/homeManagerModules/services/mako/default.nix index 2eb5f3a3..a9c8924d 100644 --- a/homeManagerModules/services/mako/default.nix +++ b/homeManagerModules/services/mako/default.nix @@ -44,7 +44,7 @@ in { Service = { BusName = "org.freedesktop.Notifications"; - Environment = ["PATH=${pkgs.lib.makeBinPath [pkgs.bash pkgs.mpv]}"]; + Environment = ["PATH=${lib.makeBinPath [pkgs.bash pkgs.mpv]}"]; ExecReload = ''${lib.getExe' pkgs.mako "makoctl"} reload''; ExecStart = "${lib.getExe pkgs.mako}"; Restart = lib.mkForce "no"; diff --git a/homeManagerModules/services/swayidle/default.nix b/homeManagerModules/services/swayidle/default.nix index 4003bb52..542def73 100644 --- a/homeManagerModules/services/swayidle/default.nix +++ b/homeManagerModules/services/swayidle/default.nix @@ -5,8 +5,6 @@ ... }: let cfg = config.ar.home; - hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"; - swaymsg = lib.getExe' config.wayland.windowManager.sway.package "swaymsg"; in { config = lib.mkIf cfg.services.swayidle.enable { services.swayidle = { @@ -15,15 +13,15 @@ in { events = [ { event = "before-sleep"; - command = "${lib.getExe pkgs.playerctl} pause"; + command = "playerctl pause"; } { event = "before-sleep"; - command = "${lib.getExe pkgs.swaylock} && ${lib.getExe' pkgs.coreutils "sleep"} 2"; + command = "swaylock && sleep 2"; } { event = "lock"; - command = "${lib.getExe pkgs.swaylock}"; + command = "swaylock"; } ]; @@ -31,36 +29,54 @@ in { [ { timeout = 120; - command = "${lib.getExe pkgs.brightnessctl} -s set 10"; - resumeCommand = "${lib.getExe pkgs.brightnessctl} -r"; + command = "brightnessctl -s set 10"; + resumeCommand = "brightnessctl -r"; } ] ++ lib.optional cfg.desktop.autoSuspend { timeout = 600; - command = "${lib.getExe' pkgs.systemd "systemctl"} suspend"; + command = "systemctl suspend"; } ++ lib.optional (!cfg.desktop.autoSuspend) { timeout = 600; - command = "${lib.getExe pkgs.swaylock}"; + command = "swaylock"; } ++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.hyprland.enable) { timeout = 630; - command = "${hyprctl} dispatch dpms off"; - resumeCommand = "${hyprctl} dispatch dpms on"; + command = "hyprctl dispatch dpms off"; + resumeCommand = "hyprctl dispatch dpms on"; } ++ lib.optional (!cfg.desktop.autoSuspend && cfg.desktop.sway.enable) { timeout = 630; - command = "${swaymsg} \"output * dpms off\""; - resumeCommand = "${swaymsg} \"output * dpms on\""; + command = "swaymsg \"output * dpms off\""; + resumeCommand = "swaymsg \"output * dpms on\""; }; }; systemd.user.services.swayidle = { Install.WantedBy = lib.mkForce (lib.optional (cfg.desktop.hyprland.enable) "hyprland-session.target" ++ lib.optional (cfg.desktop.sway.enable) "sway-session.target"); - Service.Restart = lib.mkForce "no"; + + Service = { + Environment = lib.mkForce [ + "PATH=${ + pkgs.lib.makeBinPath ((with pkgs; [ + bash + brightnessctl + coreutils + playerctl + swaylock + systemd + ]) + ++ lib.optional (cfg.desktop.hyprland.enable) config.wayland.windowManager.hyprland.package + ++ lib.optional (cfg.desktop.sway.enable) config.wayland.windowManager.sway.package) + }" + ]; + Restart = lib.mkForce "no"; + }; + Unit.BindsTo = lib.optional (cfg.desktop.hyprland.enable) "hyprland-session.target" ++ lib.optional (cfg.desktop.sway.enable) "sway-session.target"; }; };