From 8cb38f8a30be48d796b445a7b38786cc33d7f8de Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 2 Aug 2024 17:00:43 -0400 Subject: [PATCH] home: make wayland-ipewire-idle-inhibit a systemd service --- .../desktop/hyprland/settings.nix | 1 - homeManagerModules/desktop/sway/settings.nix | 1 - .../desktop/wayland/default.nix | 1 + homeManagerModules/options.nix | 1 + homeManagerModules/services/default.nix | 1 + .../services/pipewire-inhibit/default.nix | 26 +++++++++++++++++++ 6 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 homeManagerModules/services/pipewire-inhibit/default.nix diff --git a/homeManagerModules/desktop/hyprland/settings.nix b/homeManagerModules/desktop/hyprland/settings.nix index 9e3dc27b..a84c2925 100644 --- a/homeManagerModules/desktop/hyprland/settings.nix +++ b/homeManagerModules/desktop/hyprland/settings.nix @@ -127,7 +127,6 @@ in { [ "${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1" (lib.getExe pkgs.waybar) - (lib.getExe pkgs.wayland-pipewire-idle-inhibit) ] ++ lib.lists.optional (cfg.desktop.randomWallpaper) helpers.wallpaperD diff --git a/homeManagerModules/desktop/sway/settings.nix b/homeManagerModules/desktop/sway/settings.nix index 9dc9958d..07240087 100644 --- a/homeManagerModules/desktop/sway/settings.nix +++ b/homeManagerModules/desktop/sway/settings.nix @@ -159,7 +159,6 @@ in { [ {command = "${pkgs.mate.mate-polkit}/libexec/polkit-mate-authentication-agent-1";} {command = lib.getExe pkgs.autotiling;} - {command = lib.getExe pkgs.wayland-pipewire-idle-inhibit;} ] ++ lib.optional cfg.desktop.randomWallpaper {command = "${helpers.wallpaperD}";} ++ lib.optional (!cfg.desktop.randomWallpaper) {command = "${lib.getExe pkgs.swaybg} -i ${cfg.theme.wallpaper}";}; diff --git a/homeManagerModules/desktop/wayland/default.nix b/homeManagerModules/desktop/wayland/default.nix index b428b3fe..3ef166fd 100644 --- a/homeManagerModules/desktop/wayland/default.nix +++ b/homeManagerModules/desktop/wayland/default.nix @@ -15,6 +15,7 @@ services = { mako.enable = lib.mkDefault true; + pipewire-inhibit.enable = lib.mkDefault true; swayidle.enable = lib.mkDefault true; }; }; diff --git a/homeManagerModules/options.nix b/homeManagerModules/options.nix index ebc180e7..be56ebb1 100644 --- a/homeManagerModules/options.nix +++ b/homeManagerModules/options.nix @@ -218,6 +218,7 @@ in { }; }; + pipewire-inhibit.enable = lib.mkEnableOption "Inhibit idle when audio is playing with Pipewire."; swayidle.enable = lib.mkEnableOption "Swayidle idle daemon."; }; diff --git a/homeManagerModules/services/default.nix b/homeManagerModules/services/default.nix index d0105b03..a0bf7d9c 100644 --- a/homeManagerModules/services/default.nix +++ b/homeManagerModules/services/default.nix @@ -4,6 +4,7 @@ ./gammastep ./mako ./mpd + ./pipewire-inhibit ./swayidle ]; } diff --git a/homeManagerModules/services/pipewire-inhibit/default.nix b/homeManagerModules/services/pipewire-inhibit/default.nix new file mode 100644 index 00000000..ca913b98 --- /dev/null +++ b/homeManagerModules/services/pipewire-inhibit/default.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.ar.home; +in { + config = lib.mkIf cfg.services.pipewire-inhibit.enable { + systemd.user.services.pipewire-inhibit-idle = { + Unit = { + After = "graphical-session.target"; + Description = "inhibit idle when audio is playing with Pipewire."; + PartOf = "graphical-session.target"; + }; + + Service = { + ExecStart = lib.getExe pkgs.wayland-pipewire-idle-inhibit; + Restart = "on-failure"; + RestartSec = 5; + }; + + Install.WantedBy = ["hyprland-session.target" "sway-session.target"]; + }; + }; +}