yambar: add systemd service (#5469)

This commit is contained in:
Mads Rumle Nordstrøm 2025-05-30 02:12:57 +02:00 committed by GitHub
parent da282034f4
commit 2f4db1cd5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -44,6 +44,23 @@ in
See {manpage}`yambar(5)` for options.
'';
};
systemd = {
enable = lib.mkEnableOption "yambar systemd integration";
target = lib.mkOption {
type = lib.types.str;
default = config.wayland.systemd.target;
example = "sway-session.target";
description = ''
The systemd target that will automatically start the yambar service.
When setting this value to `"sway-session.target"`,
make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
otherwise the service may never be started.
'';
};
};
};
config = lib.mkIf cfg.enable {
@ -56,5 +73,26 @@ in
xdg.configFile."yambar/config.yml" = lib.mkIf (cfg.settings != { }) {
source = yamlFormat.generate "config.yml" cfg.settings;
};
systemd.user.services.yambar = lib.mkIf cfg.systemd.enable {
Unit = {
Description = "Modular status panel for X11 and Wayland";
Documentation = "man:yambar";
PartOf = [ cfg.systemd.target ];
After = [ cfg.systemd.target ];
};
Service = {
ExecStart = "${cfg.package}/bin/yambar";
ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID";
Restart = "on-failure";
RestartSec = 3;
KillMode = "mixed";
};
Install = {
WantedBy = [ cfg.systemd.target ];
};
};
};
}