From 52a0ff174b1a2043e2b7135b74febc3f06ea16cf Mon Sep 17 00:00:00 2001 From: David Warde-Farley Date: Sat, 8 Jun 2024 11:41:58 +0100 Subject: [PATCH] swayosd: add systemdTarget option --- modules/services/swayosd.nix | 13 +++++++++++-- tests/modules/services/swayosd/swayosd.nix | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) 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 '' } '';