If you are already using GNOME 3.34, then most likely your session is managed using systemd right now. For a long time now we were already running a systemd instance for every user, which is used to launch DBus and for DBus activated applications. So, with GNOME 3.34, we finally took the next step and moved the rest of the session over to run using systemd.
From a user’s perspective nothing should have changed and at this point I believe that most regressions have been dealt with. Neither will this change affect application developers for the time being as XDG autostart files continue to be supported and are prefered at least for the time being.
The great thing is, that this enables further improvements. There has been a lot of work to allow Xwayland to be started on demand and systemd plays a small part in that feature. Similar, we will also be able to shut down services that are only needed if specific hardware is present (e.g. smartcards). Also, using systemd it is now easy to sandbox all components which will give you an extra bit of security.
That said, there are a few changes, concepts and general information that is worth mentioning.
Slices, scopes and user sessions
On a systemd managed system each user is assigned a
user-X.slice (systemd.slice(5)) and the user’s session will be run in a
session-Y.scope (systemd.scope(5)). You can also see a few other user specific units on the host, including
user@X.service, which is the user’s systemd instance. This is a separate systemd process for the user and it will shut down again if the user is not logged in anymore.
With the systemd move, not only DBus activated applications and services, but rather your entire session is now launched using your user’s systemd instance. This has a few side effects that may seem odd at first. For example, the previously mentioned
session-Y.scope which used to contain over 200 processes is now down to a mere 4 processes. Another side effect is that it got harder to understand which session a process belongs to (this is relevant for a number of services) or that
ps will not show a tty anymore.
But, we have addressed these side effects and hopefully there are no regressions at this point. Your GNOME session is still invariably bound to the
session-Y.scope (e.g. using
loginctl kill-session continues to work reliably). And services have been updated to understand the new regime and pick the correct session in all cases. To handle all this, new API was also added to the systemd DBus interface and further improvements may happen in this area.
Trying it out
So, if you have GNOME 3.34, you can now apply all the neat tools that systemd has manage your user’s session. Just remember to add the
--user option, and things should work as expected. A good candidate for trying all this out is
If we look at
systemctl --user, we’ll find two entries:
Note that failed units will not show up in the list, so it is advisable to always check the log if you suspect a service failure. Unfortunately this is needed so that you can reliably log in again after a session failure.
We can control
gsd-media-keys.service), so you can try stopping and starting it and you will notice that most global keybindings will stop and start working.
systemctl --user stop gsd-media-keys.target
systemctl --user start gsd-media-keys.target
We can also pull up the log messages for the service from journalctl.
journalctl --user -u gsd-media-keys.service
But, unfortunately, it will not log much information by default. But, knowing systemd and GLib environment variables we can run:
systemctl --user --runtime edit gsd-media-keys.service
This enables debug messages when the service is restarted next. The configuration will not persist as we passed
--runtime. If you now restart
gsd-media-keys.target and inspect its log again, you will notice that it contains a lot more information.
If you have a development version of GNOME installed somewhere outside of your normal path (e.g. jhbuild) and use this to log in, then you may need to update your setup. In jhbuild there is an example jhbuild-session script that ensures that the correct unit files will be used. The relevant lines copy them into the user’s
$XDG_RUNTIME_DIRECTORY and reload the systemd daemon.
On a final note, I would like to thank everyone who has worked on this in the past. As far as I know, the first experimentations were done by Canonical, in particular Iain Lane did a lot of work and submitted the first patches. I picked up this work and made plenty of improvements to get it over the finishing line.
If you don’t have GNOME 3.34 yet, then try it out by installing Fedora 31 beta or your favourite distribution that includes GNOME 3.34 already.