[systemd-devel] Standardizing names for graphical session units

Martin Pitt martin.pitt at ubuntu.com
Wed Jul 6 11:47:40 UTC 2016


Simon McVittie [2016-07-05 10:27 +0100]:
> On 04/07/16 21:01, Martin Pitt wrote:
> > A session type like "GNOME" or "KDE" then defines which top-level
> > servcies it wants.
> 
> Could this be done by having the .desktop file in /usr/share/xsessions
> or /usr/share/wayland-sessions start an appropriate systemd user unit
> directly, and wait for it to terminate?

There is currently no command (other than a polling loop) to wait
until a particular unit gets stopped. I.  e.

  Exec=gnome-session --session=gnome

would need to be replaced with something like

  Exec=/bin/sh -c "systemctl start gnome-session.target; wait-until-service-stopped gnome-session.service; systemctl stop gnome-session.target"

and gnome-session.target pulls in gnome-session.service (which then
runs the actual gnome-session program).

Note the difference between the target (which is the whole GNOME
session) and the service (which is just the gnome-session program itself).

> > Ideally we could hook the startup of graphical.slice into the system
> > logind scope; but as the user systemd does not "see" the
> > systemd users, this isn't possible. So for now pretty much the only
> > way is to go via an /X11/xinit/xinitrc.d (Fedora) or
> > /etc/X11/Xsession.d/ (Debian) script
> 
> These scripts are a necessary evil for X11, but in the Wayland future,
> the plan (at least in GNOME) seems to be for them not to be replicated;
> if gdm is told to launch a session from /usr/share/wayland-sessions, it
> doesn't execute X11 startup script snippets. (It does have a
> gdm-specific way to set environment variables, and I'm planning to
> extend pam_env to support systemd-style .d drop-in directories to
> generalize that.) A more declarative session startup seems like a better
> session startup.

Agreed. In my original proposal I said that it might be better to let
the DMs start/stop $SESSION.target/graphical.target directly, but
indeed that's harder to change/see. Creating a nice wrapper/helper for
the above horrible Exec= line and using that in the session .desktop
file sounds better. That wrapper needs the target to start and the
"session leader unit" on whose stopping the target gets stopped as
well.

I have a gut feeling that this should be expressible with systemd
dependencies -- i. e. "if gnome-session.service stops, then stop
gnome-session.target". Naïvely this would be
"PartOf=gnome-session.target" in gnome-session.service, but this does
not currently work (that might be the same bug I mentioned in my other
reply).

> I'm not sure what you do for Mir in Ubuntu, but I'd advocate a similar
> approach - sourcing a couple of dozen Turing-complete shell script
> fragments during session startup makes it rather difficult to reason about.

Yes, this makes sense. Mir doesn't have the Xsession.d shell scriptery
either, just the .desktop file interface.

Thanks,

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


More information about the systemd-devel mailing list