User instance of systemd for session management

Goal

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.

https://bugzilla.gnome.org/show_bug.cgi?id=690866

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.

Project

Bug/MR

Status

AccountsService

https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/17

waiting

gnome-session

https://gitlab.gnome.org/GNOME/gnome-session/merge_requests/1 (preliminaries) / https://gitlab.gnome.org/GNOME/gnome-session/merge_requests/2 (use it)

waiting

gnome-shell

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/137 (find right session) / https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/138 (add units)

merged

mutter

https://gitlab.gnome.org/GNOME/mutter/merge_requests/150

merged

gnome-settings-daemon

https://gitlab.gnome.org/GNOME/gnome-settings-daemon/merge_requests/27

waiting

gdm

https://gitlab.gnome.org/GNOME/gdm/merge_requests/17 (preliminaries) / https://gitlab.gnome.org/GNOME/gdm/merge_requests/18 (use it)

waiting

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:

    • Autostart-Phase
    • Conditions
    • Only/NotShowIn
  • Start units, particularly g-s-d units, in a more smart way than all at once.

  • This enables fixing of https://bugzilla.gnome.org/show_bug.cgi?id=735869

  • 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 2018-10-25 11:04:57 by IainLane)