[gnome-session/wip/laney/systemd-user] Start sessions with systemd
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session/wip/laney/systemd-user] Start sessions with systemd
- Date: Wed, 17 Jan 2018 17:48:22 +0000 (UTC)
commit f12cf0070b397abd65f62336bf946299b561c2eb
Author: Iain Lane <iain orangesquash org uk>
Date: Wed Jan 17 12:35:22 2018 +0000
Start sessions with systemd
We add a target and a unit to start GNOME Shell under systemd, instead
of having gnome-session execute it directly.
For now GDM's session is not included in this.
The `gnome-session' script is responsible for setting up the environment
that systemd will send to further processes spawned. Further work would
be to move the environment setting code out of gnome-session itself.
data/gnome-session.service.in | 10 ++++++++++
data/gnome-session.target | 7 +++++++
data/gnome.desktop.in | 2 +-
data/gnome.session.desktop.in.in | 2 +-
data/meson.build | 21 +++++++++++++++++++++
gnome-session/gnome-session.in | 34 +++++++++++++++++++++++++++++++++-
6 files changed, 73 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-session.service.in b/data/gnome-session.service.in
new file mode 100644
index 0000000..b299d8e
--- /dev/null
+++ b/data/gnome-session.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=GNOME Session Manager
+PartOf=graphical-session.target
+After=graphical-session-pre.target
+Before=gnome-settings-daemon.target
+
+[Service]
+Type=dbus
+ExecStart=@libexecdir@/gnome-session-binary --session=gnome
+BusName=org.gnome.SessionManager
diff --git a/data/gnome-session.target b/data/gnome-session.target
new file mode 100644
index 0000000..6121111
--- /dev/null
+++ b/data/gnome-session.target
@@ -0,0 +1,7 @@
+[Unit]
+Description=User systemd services for the GNOME graphical session
+Requires=graphical-session-pre.target
+# start/tear down graphical-session.target along with the ubuntu session
+BindsTo=graphical-session.target
+# session leader -- if this dies, die along with it
+BindsTo=gnome-session.service
diff --git a/data/gnome.desktop.in b/data/gnome.desktop.in
index b54b99c..3d89a9f 100644
--- a/data/gnome.desktop.in
+++ b/data/gnome.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=GNOME
_Comment=This session logs you into GNOME
-Exec=gnome-session
+Exec=gnome-session gnome.target
TryExec=gnome-session
Icon=
Type=Application
diff --git a/data/gnome.session.desktop.in.in b/data/gnome.session.desktop.in.in
index f25cd25..276e219 100644
--- a/data/gnome.session.desktop.in.in
+++ b/data/gnome.session.desktop.in.in
@@ -1,3 +1,3 @@
[GNOME Session]
_Name=GNOME
-RequiredComponents=org.gnome.Shell;org.gnome.SettingsDaemon.A11yKeyboard;org.gnome.SettingsDaemon.A11ySettings;org.gnome.SettingsDaemon.Clipboard;org.gnome.SettingsDaemon.Color;org.gnome.SettingsDaemon.Datetime;org.gnome.SettingsDaemon.Housekeeping;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Mouse;org.gnome.SettingsDaemon.Power;org.gnome.SettingsDaemon.PrintNotifications;org.gnome.SettingsDaemon.Rfkill;org.gnome.SettingsDaemon.ScreensaverProxy;org.gnome.SettingsDaemon.Sharing;org.gnome.SettingsDaemon.Smartcard;org.gnome.SettingsDaemon.Sound;org.gnome.SettingsDaemon.Wacom;org.gnome.SettingsDaemon.XSettings;
+RequiredComponents=
diff --git a/data/meson.build b/data/meson.build
index bf7ecfa..2136451 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -71,6 +71,27 @@ install_data(
install_dir: join_paths(session_datadir, 'GConf', 'gsettings')
)
+unit_conf = configuration_data()
+unit_conf.set('libexecdir', session_libexecdir)
+
+dep_systemd = dependency('systemd', required: true)
+systemd_unitdir = dep_systemd.get_pkgconfig_variable('systemduserunitdir')
+
+configure_file(
+ input: 'gnome-session.service.in',
+ output: 'gnome-session.service',
+ install: true,
+ install_dir: systemd_unitdir,
+ configuration: unit_conf
+)
+
+systemd_target = files('gnome-session.target')
+
+install_data(
+ systemd_target,
+ install_dir: systemd_unitdir
+)
+
data = files('hardware-compatibility')
if enable_session_selector
diff --git a/gnome-session/gnome-session.in b/gnome-session/gnome-session.in
index ce63df5..80920fa 100755
--- a/gnome-session/gnome-session.in
+++ b/gnome-session/gnome-session.in
@@ -25,4 +25,36 @@ if [ -n "$REGION" ]; then
export LC_PAPER=$REGION
fi
-exec @libexecdir@/gnome-session-binary "$@"
+if [ ${RUNNING_UNDER_GDM:-false} = true ]; then
+ # At the moment we don't run GDM in a full systemd session
+ exec /usr/lib/gnome-session/gnome-session-binary "$@"
+else
+ # stop any lingering active units from a previous session
+ systemctl --user stop --wait graphical-session.target graphical-session-pre.target
+
+ # robustness: if the previous graphical session left some failed units,
+ # reset them so that they don't break this startup
+ for unit in $(systemctl --user --no-legend --state=failed list-units | cut -f1 -d' '); do
+ if [ "$(systemctl --user show -p PartOf --value $unit)" = "graphical-session.target" ]; then
+ systemctl --user reset-failed $unit
+ fi
+ done
+
+ # subshell so we can unset environment variables
+ (
+ # unset login-session-specifics
+ unset XDG_SEAT
+ unset XDG_SESSION_ID
+ unset XDG_VTNR
+
+ unset DISPLAY
+
+ # tell dbus-daemon --session (and systemd --user, if running)
+ # to put the our current environment in activated services' environments
+
+ # XXX: Move this elsewhere (relocate the equivalent code in gnome-session
+ # itself to a standalone binary?)
+ dbus-update-activation-environment --verbose --systemd --all
+ )
+ systemctl --user start --wait "$@"
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]