waybar: configurable systemd WantedBy target (#2524)

Before this commit, a user needed to override the systemd target that
would start Waybar with `mkForce`, this is no longer necessary.
This commit is contained in:
Nicolas Berbiche 2021-12-23 17:00:31 -05:00 committed by GitHub
parent 3b9c625b64
commit f15b151ca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -197,6 +197,20 @@ in {
systemd.enable = mkEnableOption "Waybar systemd integration";
systemd.target = mkOption {
type = str;
default = "graphical-session.target";
example = "sway-session.target";
description = ''
The systemd target that will automatically start the Waybar service.
</para>
<para>
When setting this value to <literal>"sway-session.target"</literal>,
make sure to also enable <option>wayland.windowManager.sway.systemdIntegration</option>,
otherwise the service may never be started.
'';
};
style = mkOption {
type = nullOr (either path str);
default = null;
@ -309,7 +323,7 @@ in {
KillMode = "mixed";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ cfg.systemd.target ]; };
};
})
]);

View File

@ -10,6 +10,7 @@ with lib;
package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true;
systemd.enable = true;
systemd.target = "sway-session.target";
};
nmt.script = ''

View File

@ -1,5 +1,5 @@
[Install]
WantedBy=graphical-session.target
WantedBy=sway-session.target
[Service]
ExecReload=kill -SIGUSR2 $MAINPID