Systemd - how to properly terminate a graphical sesion?

I noticed something odd.

I have a bunch of user services that get properly started when I log into my session. (sway via regreet)

Before I log in systemctl --user status and some other services that depend on it are dead.

Once I log in, they become active.

But No matter how I log out, they don’t terminate right. So if I re-login they are all not re-started.

I tried to just exit sway. Also via loginctl terminate-session but the graphical session target remains active. (Also

If I stop graphical-session after I log out it all works again.

Can someone confirm the same behavior with other login managers? GDM perhaps?

Any idea what magic is missing?

My config: and

regreet is set up rather minimalistic

  services.xserver = {
    enable = true;
    videoDrivers = [
    desktopManager = {
      xterm.enable = false;
  programs.regreet = {
    enable = true;
    settings.background = {
      path = pkgs.nixos-artwork.wallpapers.stripes-logo.gnomeFilePath;
      fit = "Cover";

PS: If I enable wayland.windowManager.sway.systemd.xdgAutostart then those auto-start services all also go to failed when I re-login

› cat /home/tilli/.config/systemd/user/

Description=sway compositor session

BindsTo= is a directional dependency that makes start and stop with

But it only goes that direction. There is nothing making the go down with sway…

Plot thickens. Seems like stopping takes down too. I was looking at the wrong place.

sway starts those targets. :monkey:


exec "/nix/store/m9bp68sxl8pi3gxhplfg8cgmld9c2lc0-dbus-1.14.10/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL; systemctl --user start"

I think logind is supposed to do all that stuff…

I think greetd needs to tell logind that the ssession is closed so that this target gets stopped.

I’m still not a 100% clear on how it’s done right.

GDM can do it. And does even somehow support multiple sessions.
Xsession does it right too.

Something regressed badly with plain wayland sessions.

There is a sway specific workaround and I’m tempted to use it.

But this issue will affect all wayland sessions not started via GDM/KDE not just sway.

This is how xsession does it