From c92fcc4f4375b0aebc5919311bbf703138b21918 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 25 Jul 2016 22:01:35 +0200 Subject: [PATCH] units: add graphical-session.target user unit (#3678) This unit acts as a dynamic "alias" target for any concrete graphical user session like gnome-session.target; these should declare "BindsTo=graphical-session.target" so that both targets stop and start at the same time. This allows services that run in a particular graphical user session (e. g. gnome-settings-daemon.service) to declare "PartOf=graphical-session.target" without having to know or get updated for all/new session types. This will ensure that stopping the graphical session will stop all services which are associated to it. --- Makefile.am | 3 +- man/systemd.special.xml | 51 +++++++++++++++++++++++++++++ units/user/graphical-session.target | 13 ++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 units/user/graphical-session.target diff --git a/Makefile.am b/Makefile.am index 0c27f819863..c1e1c63634b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -573,7 +573,8 @@ endif dist_userunit_DATA = \ units/user/basic.target \ units/user/default.target \ - units/user/exit.target + units/user/exit.target \ + units/user/graphical-session.target nodist_userunit_DATA = \ units/user/systemd-exit.service diff --git a/man/systemd.special.xml b/man/systemd.special.xml index 18ad8f92e55..18142598cbd 100644 --- a/man/systemd.special.xml +++ b/man/systemd.special.xml @@ -878,6 +878,57 @@ sound.target. + + Special Passive User Units + + + graphical-session.target + + This target is active whenever any graphical session is running. It + is used to stop user services which only apply to a graphical (X, + Wayland, etc.) session when the session is terminated. Such services + should have PartOf=graphical-session.target in their + [Unit] section. A target for a particular session + (e. g. gnome-session.target) starts and stops + graphical-session.target with + BindsTo=graphical-session.target. + + Which services are started by a session target is determined by the + Wants= and Requires= dependencies. + For services that can be enabled independently, symlinks in + .wants/ and .requires/ should be + used, see + systemd.unit5. + Those symlinks should either be shipped in packages, or should be added + dynamically after installation, for example using systemctl add-wants, see + systemctl1. + + + + Nautilus as part of a GNOME session + + gnome-session.target pulls in Nautilus as + top-level service: + + [Unit] +Description=User systemd services for GNOME graphical session +Wants=nautilus.service +BindsTo=graphical-session.target + + + nautilus.service gets stopped when the session stops: + + [Unit] +Description=Render the desktop icons with Nautilus +PartOf=graphical-session.target + +[Service] +... + + + + + Special Slice Units diff --git a/units/user/graphical-session.target b/units/user/graphical-session.target new file mode 100644 index 00000000000..00d16230b78 --- /dev/null +++ b/units/user/graphical-session.target @@ -0,0 +1,13 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Current graphical user session +Documentation=man:systemd.special(7) +Requires=basic.target +RefuseManualStart=yes +StopWhenUnneeded=yes -- 2.39.2