From 615f913955d10d72560ad0dfecca9b281004ce08 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 31 Aug 2024 23:59:14 +0200 Subject: [PATCH] treewide: use graphical-session.target for GUI services As per systemd.special(7)[0] graphical-session-pre.target is strictly for units that set up things for a graphical session. Most notably, these are usually started *before* the compositor/session is actually ready. While Home Manager's current implementation of graphical-session.target allows these units to work regardless of what systemd.special(7) specifies, other setups like ones with uwsm[1] do not allow these units to start properly. [0]: https://www.freedesktop.org/software/systemd/man/latest/systemd.special.html#graphical-session-pre.target [1]: https://github.com/Vladimir-csp/uwsm Signed-off-by: Sefa Eyeoglu --- modules/programs/waybar.nix | 2 +- modules/services/blueman-applet.nix | 2 +- modules/services/network-manager-applet.nix | 2 +- modules/services/poweralertd.nix | 2 +- modules/services/swayidle.nix | 1 + modules/services/wlsunset.nix | 1 + .../waybar/systemd-with-graphical-session-target.service | 2 +- tests/modules/services/swayidle/basic-configuration.nix | 1 + .../modules/services/wlsunset/wlsunset-service-expected.service | 1 + 9 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/programs/waybar.nix b/modules/programs/waybar.nix index 72d247323fb8..3d6ead7573ae 100644 --- a/modules/programs/waybar.nix +++ b/modules/programs/waybar.nix @@ -309,7 +309,7 @@ in { "Highly customizable Wayland bar for Sway and Wlroots based compositors."; Documentation = "https://github.com/Alexays/Waybar/wiki"; PartOf = [ "graphical-session.target" ]; - After = [ "graphical-session-pre.target" ]; + After = [ "graphical-session.target" ]; }; Service = { diff --git a/modules/services/blueman-applet.nix b/modules/services/blueman-applet.nix index 5211534c4b21..47f81b48cfda 100644 --- a/modules/services/blueman-applet.nix +++ b/modules/services/blueman-applet.nix @@ -30,7 +30,7 @@ with lib; Unit = { Description = "Blueman applet"; Requires = [ "tray.target" ]; - After = [ "graphical-session-pre.target" "tray.target" ]; + After = [ "graphical-session.target" "tray.target" ]; PartOf = [ "graphical-session.target" ]; }; diff --git a/modules/services/network-manager-applet.nix b/modules/services/network-manager-applet.nix index 524921b71d9a..75bdf9d511fc 100644 --- a/modules/services/network-manager-applet.nix +++ b/modules/services/network-manager-applet.nix @@ -28,7 +28,7 @@ in { Unit = { Description = "Network Manager applet"; Requires = [ "tray.target" ]; - After = [ "graphical-session-pre.target" "tray.target" ]; + After = [ "graphical-session.target" "tray.target" ]; PartOf = [ "graphical-session.target" ]; }; diff --git a/modules/services/poweralertd.nix b/modules/services/poweralertd.nix index 9c59ad3f04ea..20481e905f07 100644 --- a/modules/services/poweralertd.nix +++ b/modules/services/poweralertd.nix @@ -44,7 +44,7 @@ in { Unit = { Description = "UPower-powered power alerter"; Documentation = "man:poweralertd(1)"; - After = [ "graphical-session-pre.target" ]; + After = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ]; }; diff --git a/modules/services/swayidle.nix b/modules/services/swayidle.nix index 7f3376a1ce42..31ef00324013 100644 --- a/modules/services/swayidle.nix +++ b/modules/services/swayidle.nix @@ -107,6 +107,7 @@ in { Description = "Idle manager for Wayland"; Documentation = "man:swayidle(1)"; ConditionEnvironment = "WAYLAND_DISPLAY"; + After = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ]; }; diff --git a/modules/services/wlsunset.nix b/modules/services/wlsunset.nix index f3352750c137..4bbd98e0be08 100644 --- a/modules/services/wlsunset.nix +++ b/modules/services/wlsunset.nix @@ -128,6 +128,7 @@ in { systemd.user.services.wlsunset = { Unit = { Description = "Day/night gamma adjustments for Wayland compositors."; + After = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ]; }; diff --git a/tests/modules/programs/waybar/systemd-with-graphical-session-target.service b/tests/modules/programs/waybar/systemd-with-graphical-session-target.service index c99c8c13ac17..e1343da8a813 100644 --- a/tests/modules/programs/waybar/systemd-with-graphical-session-target.service +++ b/tests/modules/programs/waybar/systemd-with-graphical-session-target.service @@ -8,7 +8,7 @@ KillMode=mixed Restart=on-failure [Unit] -After=graphical-session-pre.target +After=graphical-session.target Description=Highly customizable Wayland bar for Sway and Wlroots based compositors. Documentation=https://github.com/Alexays/Waybar/wiki PartOf=graphical-session.target diff --git a/tests/modules/services/swayidle/basic-configuration.nix b/tests/modules/services/swayidle/basic-configuration.nix index c38f4d67d86e..2ff5941bba5d 100644 --- a/tests/modules/services/swayidle/basic-configuration.nix +++ b/tests/modules/services/swayidle/basic-configuration.nix @@ -50,6 +50,7 @@ Type=simple [Unit] + After=graphical-session.target ConditionEnvironment=WAYLAND_DISPLAY Description=Idle manager for Wayland Documentation=man:swayidle(1) diff --git a/tests/modules/services/wlsunset/wlsunset-service-expected.service b/tests/modules/services/wlsunset/wlsunset-service-expected.service index fecd05b9f523..d4006618f470 100644 --- a/tests/modules/services/wlsunset/wlsunset-service-expected.service +++ b/tests/modules/services/wlsunset/wlsunset-service-expected.service @@ -5,5 +5,6 @@ WantedBy=test.target ExecStart=@wlsunset@/bin/wlsunset -L 128.8 -T 6000 -g 0.6 -l 12.3 -t 3500 [Unit] +After=graphical-session.target Description=Day/night gamma adjustments for Wayland compositors. PartOf=graphical-session.target