[systemd-devel] Standardizing names for graphical session units -- version 2

Martin Pitt martin.pitt at ubuntu.com
Wed Jul 6 11:25:56 UTC 2016


Hello all,

Colin, Jan, Zbigniew, thanks for your input! Based on that I have an
updated proposal.

Jan Alexander Steffens [2016-07-06  9:44 +0000]:
> On Wed, Jul 6, 2016 at 10:51 AM Colin Guthrie <gmane at colin.guthr.ie> wrote:
> > Not commenting on the general approach (which I did read and broadly
> > agree with without giving it too much thought!), but could you use
> > PartOf= here to make the target approach work? It might be more hacky as
> > each user .service would have to declare themselves to be PartOf the
> > corresponding .target. This does mean that if the target is stopped, the
> > units are stopped too.
> >
> > I'm not sure how this would work regarding things like g-s-d which you
> > want in multiple DEs.. perhaps the gnome.target would have to be split
> > up into gnome-base.target and gnome.target to allow for this use case?
> > Or perhaps g-s-d could just become bus activated and not need any direct
> > starting?
> >
> 
> How about a top-level, generic graphical.target that defines no
> dependencies itself, but is Required by anything graphical. Then stopping
> graphical.target would terminate the desktop, no matter which environment
> was set up.

This indeed mostly works. So this would have three parts:

 * systemd ships a new user unit "graphical.target", symmetric to the
   system unit:

   $ cat .config/systemd/user/graphical.target
   [Unit]
   Description=User systemd services for graphical session

   This isn't enabled anywhere, so it's completely inert on servers,
   ssh/VT sessions, etc.


 * gnome-session and friends, which currently ship e. g.
   /usr/share/xsessions/gnome.desktop, ship a corresponding
   gnome-session.target:

   $ cat .config/systemd/user/gnome-session.target
   [Unit]
   Description=User systemd services for GNOME graphical session
   Requires=graphical.target
   PartOf=graphical.target

 * Applications ship services which are PartOf=graphical.target,  so
   that they go down with the graphical session:

   cat .config/systemd/user/someapp.service
   [Unit]
   Description=example graphical app
   PartOf=graphical.target
   [Service]
   ExecStart=/bin/sleep infinity

   graphical.target is the thing we set/ship in systemd, so it's not
   dependent on which particular DE/session you use.

 * The GNOME session package (which ships gnome.desktop and
   gnome-session.target) depends on the things it needs (like
   gnome-session, mutter, etc.) and also ships the top-level
   enablement symlinks:

   .config/systemd/user/gnome-session.target.wants/someapp.service -> ../someapp.service

   This also retains the option that an app auto-starts itself in all
   graphical sessions by shipping a graphical.target.wants/ symlink to
   themselves (but this shouldn't be a common case).

Now "systemctl --user start gnome-session.target" starts
graphical.target (through g-s.t's Requires) and myapp.service (via
gnome-session.target.wants/). And "systemctl --user stop graphical.target"
stops all three (via the PartOf=).

The only glitch is that "systemctl --user stop gnome-session.target"
only stops that target itself. I would have expected it to stop
graphical.target too (and someapp along with it), as it has
PartOf=graphical.target. This might be a bug in systemd, or some
semantics of PartOf with targets that I don't understand. However,
always stopping graphical.target when the session stops seems safer
anyway.

(The XSession.d/xinit.d bits to actually start/stop the targets are
unaffected by this change; I'll follow up to Simon's reply about that).

So again, the only change we should do in systemd is to ship the
graphical.target user unit.

WDYT?

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