diff --git a/modules/services/hypridle.nix b/modules/services/hypridle.nix index 0e28c5438..75c5e2ec7 100644 --- a/modules/services/hypridle.nix +++ b/modules/services/hypridle.nix @@ -11,6 +11,20 @@ in { package = mkPackageOption pkgs "hypridle" { }; + systemd = { + enable = lib.mkEnableOption "Hypridle Systemd integration" // { + default = true; + }; + target = lib.mkOption { + type = lib.types.str; + default = "graphical-session.target"; + example = "hyprland-session.target"; + description = '' + The systemd target that will automatically start the hypridle service. + ''; + }; + }; + settings = lib.mkOption { type = with lib.types; let @@ -73,8 +87,8 @@ in { }; }; - systemd.user.services.hypridle = { - Install = { WantedBy = [ "graphical-session.target" ]; }; + systemd.user.services.hypridle = mkIf cfg.systemd.enable { + Install = { WantedBy = [ cfg.systemd.target ]; }; Unit = { ConditionEnvironment = "WAYLAND_DISPLAY"; diff --git a/tests/modules/services/hypridle/basic-configuration.nix b/tests/modules/services/hypridle/basic-configuration.nix index 461f70a51..ca03e15f2 100644 --- a/tests/modules/services/hypridle/basic-configuration.nix +++ b/tests/modules/services/hypridle/basic-configuration.nix @@ -5,6 +5,8 @@ enable = true; package = pkgs.hypridle; + systemd.target = "hyprland-session.target"; + settings = { general = { after_sleep_cmd = "hyprctl dispatch dpms on"; @@ -34,5 +36,6 @@ assertFileExists $config assertFileExists $clientServiceFile assertFileContent $config ${./hypridle.conf} + assertFileContains $clientServiceFile "WantedBy=hyprland-session.target" ''; }