diff --git a/modules/services/swayosd.nix b/modules/services/swayosd.nix index 79ca7f5ee..977fbd018 100644 --- a/modules/services/swayosd.nix +++ b/modules/services/swayosd.nix @@ -43,6 +43,15 @@ in { X display to use. ''; }; + + systemdTarget = mkOption { + type = types.str; + default = "graphical-session.target"; + example = "sway-session.target"; + description = '' + Systemd target to bind to. + ''; + }; }; config = mkIf cfg.enable { @@ -56,8 +65,8 @@ in { services.swayosd = { Unit = { Description = "Volume/backlight OSD indicator"; - PartOf = [ "graphical-session.target" ]; - After = [ "graphical-session.target" ]; + PartOf = [ cfg.systemdTarget ]; + After = [ cfg.systemdTarget ]; ConditionEnvironment = "WAYLAND_DISPLAY"; Documentation = "man:swayosd(1)"; }; diff --git a/tests/modules/services/swayosd/swayosd.nix b/tests/modules/services/swayosd/swayosd.nix index 88a7c5362..f465e986f 100644 --- a/tests/modules/services/swayosd/swayosd.nix +++ b/tests/modules/services/swayosd/swayosd.nix @@ -10,6 +10,7 @@ display = "DISPLAY"; stylePath = "/etc/xdg/swayosd/style.css"; topMargin = 0.1; + systemdTarget = "test.target"; }; nmt.script = '' @@ -26,11 +27,11 @@ Type=simple [Unit] - After=graphical-session.target + After=test.target ConditionEnvironment=WAYLAND_DISPLAY Description=Volume/backlight OSD indicator Documentation=man:swayosd(1) - PartOf=graphical-session.target + PartOf=test.target '' } '';