User instance of systemd for session management


Instead of gnome-session spawning the components required by a session, use systemd --user.

To enable a soft transition, we intend to continue supporting the current way of starting sessions for a couple of cycles. After this we'll review and we are likely then to reduce the scope of gnome-session by removing its session spawning support, D-Bus API and so on. After this we will require the use of systemd --user for session starting.

Current status

Several projects need preparatory commits. The main reason is that programs spawned by systemd are outside of the user's logind session, and so code along the lines of sd_pid_get_session (getpid(), &session); will not work. Instead such code needs to be refactored to find the user's "display" session, or the "greeter" session for GDM. We already don't support the same user logging in multiple times to the same machine simultaneously, so there should be no regressions caused by this. These commits ought to be safe to land at any point.

Other projects will need to ship unit files. If they ship autostart files which are being replaced by units, they need to install Hidden=true copies of the autostart desktop files into $datadir/gnome-session/systemd-user/autostart so they are not started when the unit is. This can also be done at any point, as it is a noop when things are started directly.

A new session entry point, gnome-session-systemd, is provided. This takes one argument, the unit (usually a .target unit) to start to kick off the session. It'll perform some cleanup functions, intitialise the systemd environment, and then start the unit & hang around until it stops again. Sessions opt in to being started in this way by modifying their Exec lines and removing RequiredComponents.








gnome-shell (find right session) / (add units); other updates:









Needs to export variables early on; currently still done by gnome-session compatibility layer

no patch yet

Future work

  • Remove Exec support and have the unit specified declaratively.

  • In GDM, the default (greeter) session is currently the only supported session. Support others, like gnome-initial-setup.

  • Deprecate XDG autostart, possibly by using a generator to create units out of them. Will need to handle:

  • Start units, particularly g-s-d units, in a more smart way than all at once.

  • This enables fixing of

  • Find a common place for "find the display session for this user" function
  • Fix spice-vdagent so that you can have nicely sized VMs in virt-manager et al

Initiatives/SystemdUser (last edited 2019-12-09 14:12:54 by BenjaminBerg)