Add systemd target tray.target (#2027)

This target is for systemd units that require a system tray to be
running.

This also fixes taffybar.service: previously, systemd would consider it
to be active (running) before it was actually ready to accept tray
icons.
This commit is contained in:
Nick Hu 2021-05-22 03:15:12 +01:00 committed by GitHub
parent 82ab1ad467
commit 4f70f49cec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 48 additions and 45 deletions

View file

@ -24,7 +24,8 @@ with lib;
systemd.user.services.blueman-applet = {
Unit = {
Description = "Blueman applet";
After = [ "graphical-session-pre.target" ];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -103,7 +103,8 @@ in {
systemd.user.services.cbatticon = {
Unit = {
Description = "cbatticon system tray battery icon";
After = [ "graphical-session-pre.target" ];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -18,12 +18,8 @@ in {
systemd.user.services.flameshot = {
Unit = {
Description = "Flameshot screenshot tool";
After = [
"graphical-session-pre.target"
"polybar.service"
"stalonetray.service"
"taffybar.service"
];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -19,7 +19,8 @@ in {
systemd.user.services.network-manager-applet = {
Unit = {
Description = "Network Manager applet";
After = [ "graphical-session-pre.target" ];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -27,7 +27,8 @@ in {
systemd.user.services.parcellite = {
Unit = {
Description = "Lightweight GTK+ clipboard manager";
After = [ "graphical-session-pre.target" ];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -13,7 +13,8 @@ with lib;
systemd.user.services.pasystray = {
Unit = {
Description = "PulseAudio system tray";
After = [ "graphical-session-pre.target" ];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -197,8 +197,7 @@ in {
systemd.user.services.polybar = {
Unit = {
Description = "Polybar status bar";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
PartOf = [ "tray.target" ];
X-Restart-Triggers =
[ "${config.xdg.configFile."polybar/config".source}" ];
};
@ -212,7 +211,7 @@ in {
Restart = "on-failure";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ "tray.target" ]; };
};
};

View file

@ -56,11 +56,10 @@ in {
systemd.user.services.stalonetray = {
Unit = {
Description = "Stalonetray system tray";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
PartOf = [ "tray.target" ];
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ "tray.target" ]; };
Service = {
ExecStart = "${cfg.package}/bin/stalonetray";

View file

@ -29,16 +29,17 @@ in {
systemd.user.services.status-notifier-watcher = {
Unit = {
Description = "SNI watcher";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
PartOf = [ "tray.target" ];
Before = [ "taffybar.service" ];
};
Service = { ExecStart = "${cfg.package}/bin/status-notifier-watcher"; };
Install = {
WantedBy = [ "graphical-session.target" "taffybar.service" ];
Service = {
Type = "dbus";
BusName = "org.kde.StatusNotifierWatcher";
ExecStart = "${cfg.package}/bin/status-notifier-watcher";
};
Install = { WantedBy = [ "tray.target" "taffybar.service" ]; };
};
};
}

View file

@ -74,12 +74,8 @@ with lib;
${config.services.syncthing.tray.package.pname} = {
Unit = {
Description = config.services.syncthing.tray.package.pname;
After = [
"graphical-session-pre.target"
"polybar.service"
"taffybar.service"
"stalonetray.service"
];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};
@ -100,12 +96,8 @@ with lib;
"syncthingtray" = {
Unit = {
Description = "syncthingtray";
After = [
"graphical-session-pre.target"
"polybar.service"
"taffybar.service"
"stalonetray.service"
];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -27,16 +27,17 @@ in {
systemd.user.services.taffybar = {
Unit = {
Description = "Taffybar desktop bar";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
PartOf = [ "tray.target" ];
};
Service = {
Type = "dbus";
BusName = "org.taffybar.Bar";
ExecStart = "${cfg.package}/bin/taffybar";
Restart = "on-failure";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Install = { WantedBy = [ "tray.target" ]; };
};
xsession.importedVariables = [ "GDK_PIXBUF_MODULE_FILE" ];

View file

@ -77,7 +77,8 @@ in {
systemd.user.services.udiskie = {
Unit = {
Description = "udiskie mount daemon";
After = [ "graphical-session-pre.target" ];
Requires = [ "tray.target" ];
After = [ "graphical-session-pre.target" "tray.target" ];
PartOf = [ "graphical-session.target" ];
};

View file

@ -110,12 +110,21 @@ in {
};
};
# A basic graphical session target for Home Manager.
targets.hm-graphical-session = {
Unit = {
Description = "Home Manager X session";
Requires = [ "graphical-session-pre.target" ];
BindsTo = [ "graphical-session.target" ];
targets = {
# A basic graphical session target for Home Manager.
hm-graphical-session = {
Unit = {
Description = "Home Manager X session";
Requires = [ "graphical-session-pre.target" ];
BindsTo = [ "graphical-session.target" "tray.target" ];
};
};
tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = [ "graphical-session-pre.target" ];
};
};
};
};