[gnome-session/wip/benzea/systemd-user-switch: 3/7] data: Add systemd user units
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session/wip/benzea/systemd-user-switch: 3/7] data: Add systemd user units
- Date: Fri, 26 Apr 2019 08:19:46 +0000 (UTC)
commit fc62943b08597045d080efeba2df9884056d58f5
Author: Benjamin Berg <bberg redhat com>
Date: Sat Apr 20 01:49:21 2019 +0200
data: Add systemd user units
The structure is like this:
* gnome-session.target:
Main target that we will reach eventually
* gnome-session-pre.target:
Early intialization, run before gnome-session-manager starts
* gnome-session-manager.target:
Reached after early XDG initalization by the manager
* gnome-session-initialized.target:
Systemd applications must run before this to modify the environment.
This is effectively used for gnome-shell.
Manager continues starting XDG applications after this is reached.
* gnome-session-shutdown.target:
Started to shutdown the session. Makes sure everything is cleaned up
in the end.
* gnome-session@.target:
Template unit which has the GNOME session name in its template. May
be used by units to only start in certain session.
Based on work by Iain Lane <iainl gnome org>.
data/gnome-session-ctl service in | 9 ++++++++
data/gnome-session-failed.service.in | 16 ++++++++++++++
data/gnome-session-failed.target | 11 ++++++++++
data/gnome-session-initialized.target | 13 ++++++++++++
data/gnome-session-manager.target | 5 +++++
data/gnome-session-manager service in | 28 +++++++++++++++++++++++++
data/gnome-session-pre.target | 10 +++++++++
data/gnome-session-shutdown.target | 24 +++++++++++++++++++++
data/gnome-session.target | 7 +++++++
data/gnome-session@.target | 26 +++++++++++++++++++++++
data/gnome-wayland.desktop.in.in | 7 +++++++
data/meson.build | 38 ++++++++++++++++++++++++++++++++++
12 files changed, 194 insertions(+)
---
diff --git a/data/gnome-session-ctl service in b/data/gnome-session-ctl service in
new file mode 100644
index 00000000..9ce40791
--- /dev/null
+++ b/data/gnome-session-ctl service in
@@ -0,0 +1,9 @@
+[Unit]
+Description=GNOME Session Manager controller (task: %i)
+# The watch process which pulls down the session leader should be stopped last.
+Before=graphical-target.target
+
+[Service]
+Type=notify
+ExecStart=@libexecdir@/gnome-session-ctl --%i
+TimeoutStopSec=5
diff --git a/data/gnome-session-failed.service.in b/data/gnome-session-failed.service.in
new file mode 100644
index 00000000..2fc5c251
--- /dev/null
+++ b/data/gnome-session-failed.service.in
@@ -0,0 +1,16 @@
+[Unit]
+Description=GNOME Session failure lockdown (user)
+
+PartOf=gnome-session-failed.target
+
+# We could do this, but it requires an intermediate target for OnFailure
+# handling, so gnome-session-failed checks RUNNING_UNDER_GDM itself
+#Conflicts=gnome-session@gnome-login.target
+# or in the case of GDM and then not passing --allow-logout
+#Requisite=gnome-session@gnome-login.target
+
+[Service]
+Type=simple
+ExecStart=@libexecdir@/gnome-session-failed --allow-logout
+# The fail whale doesn't trigger a shutdown itself, so do it here
+ExecStopPost=-@libexecdir@/gnome-session-ctl --shutdown
diff --git a/data/gnome-session-failed.target b/data/gnome-session-failed.target
new file mode 100644
index 00000000..8cb5f51a
--- /dev/null
+++ b/data/gnome-session-failed.target
@@ -0,0 +1,11 @@
+[Unit]
+Description=GNOME Session Failed
+OnFailure=gnome-session-shutdown.target
+
+# We need an initialized session
+Requisite=gnome-session-initialized.target
+After=gnome-session-initialized.target
+BindsTo=gnome-session-initialized.target
+
+Requires=gnome-session-failed.service
+Before=gnome-session-failed.service
diff --git a/data/gnome-session-initialized.target b/data/gnome-session-initialized.target
new file mode 100644
index 00000000..eb036f24
--- /dev/null
+++ b/data/gnome-session-initialized.target
@@ -0,0 +1,13 @@
+[Unit]
+Description=GNOME Session is initialized
+RefuseManualStart=true
+DefaultDependencies=false
+
+Requires=gnome-session.target
+Before=gnome-session.target
+PartOf=gnome-session.target
+
+# Signal gnome-session that we reached the initialized target and
+# that it may start applications.
+Requires=gnome-session-ctl@signal-init.service
+Before=gnome-session-ctl@signal-init.service
diff --git a/data/gnome-session-manager.target b/data/gnome-session-manager.target
new file mode 100644
index 00000000..eecbc3d2
--- /dev/null
+++ b/data/gnome-session-manager.target
@@ -0,0 +1,5 @@
+[Unit]
+Description=GNOME Session Manager is ready
+RefuseManualStart=true
+
+PartOf=gnome-session-initialized.target
diff --git a/data/gnome-session-manager service in b/data/gnome-session-manager service in
new file mode 100644
index 00000000..18d0c461
--- /dev/null
+++ b/data/gnome-session-manager service in
@@ -0,0 +1,28 @@
+[Unit]
+Description=GNOME Session Manager (session: %i)
+RefuseManualStart=true
+OnFailure=gnome-session-shutdown.target
+
+# Pre-session sync point
+Requires=gnome-session-pre.target
+After=gnome-session-pre.target
+
+# g-s-m sync point, g-s-m is up and stared the initialization XDG targets
+Requires=gnome-session-manager.target
+PartOf=gnome-session-manager.target
+Before=gnome-session-manager.target
+
+# Initialization sync point, shell is up at this point
+Requires=gnome-session-initialized.target
+PartOf=gnome-session-initialized.target
+Before=gnome-session-initialized.target
+
+# Session is up sync point
+Requires=gnome-session.target
+PartOf=gnome-session.target
+Before=gnome-session.target
+
+[Service]
+Type=notify
+ExecStart=@libexecdir@/gnome-session-binary --debug --systemd --session=%i
+ExecStopPost=-@libexecdir@/gnome-session-ctl --shutdown
diff --git a/data/gnome-session-pre.target b/data/gnome-session-pre.target
new file mode 100644
index 00000000..5e72fca8
--- /dev/null
+++ b/data/gnome-session-pre.target
@@ -0,0 +1,10 @@
+[Unit]
+Description=Tasks to be run before GNOME Session starts
+Requisite=gnome-session.target
+Before=gnome-session.target
+PartOf=gnome-session.target
+
+Requires=graphical-session-pre.target
+Before=graphical-session-pre.target
+PartOf=graphical-session-pre.target
+
diff --git a/data/gnome-session-shutdown.target b/data/gnome-session-shutdown.target
new file mode 100644
index 00000000..0ee5fc5d
--- /dev/null
+++ b/data/gnome-session-shutdown.target
@@ -0,0 +1,24 @@
+[Unit]
+Description=Shutdown running GNOME Session
+
+Conflicts=graphical-session.target graphical-session-pre.target
+After=graphical-session.target graphical-session-pre.target
+
+# Add explicit conflicts/after lines for gnome-session targets, this shouldn't
+# be needed, but ensures proper cleanup when there is a failure during startup.
+Conflicts=gnome-session.target gnome-session-manager.target
+After=gnome-session.target gnome-session-manager.target
+
+Conflicts=gnome-session-pre.target gnome-session-initialized.target gnome-session-failed.target
+After=gnome-session-pre.target gnome-session-initialized.target gnome-session-failed.target
+
+# Could we set StopWhenUnneeded=true or would that prevent the service to start?
+
+# We trigger a restart of DBus after reaching the shutdown target this
+# is a workaround so that DBus services that do not connect to the
+# display server are shut down after log-out.
+# This should be removed when the relevant services add a
+# PartOf=graphical-session.target
+# Historic bug: https://bugzilla.gnome.org/show_bug.cgi?id=764029
+Wants=gnome-session-ctl@restart-dbus.service
+Before=gnome-session-ctl@restart-dbus.service
diff --git a/data/gnome-session.target b/data/gnome-session.target
new file mode 100644
index 00000000..d4387758
--- /dev/null
+++ b/data/gnome-session.target
@@ -0,0 +1,7 @@
+[Unit]
+Description=GNOME Session
+Requires=graphical-session.target
+PartOf=graphical-session.target
+Before=graphical-session.target
+
+RefuseManualStart=true
diff --git a/data/gnome-session@.target b/data/gnome-session@.target
new file mode 100644
index 00000000..59a8ef27
--- /dev/null
+++ b/data/gnome-session@.target
@@ -0,0 +1,26 @@
+[Unit]
+Description=GNOME Session (session: %i)
+# gnome-session-ctl@monitor.service will quit with the session leader process
+# gnome-session.target pulls in graphical-session.target
+Requires=gnome-session-ctl@monitor.service
+After=gnome-session-ctl@monitor.service
+
+Requisite=gnome-session.target
+PartOf=gnome-session.target
+Before=gnome-session.target
+
+Requires=gnome-session-pre.target
+After=gnome-session-pre.target
+
+Requires=gnome-session-manager@.service
+After=gnome-session-manager@.service
+
+Requires=gnome-session-initialized.target
+Before=gnome-session-initialized.target
+
+# We really need gnome-shell as part of any gnome-session
+Requires=gnome-shell.target
+
+# We currently start this target explicitly from the gnome-session leader process
+#RefuseManualStart=true
+
diff --git a/data/gnome-wayland.desktop.in.in b/data/gnome-wayland.desktop.in.in
new file mode 100644
index 00000000..516c211e
--- /dev/null
+++ b/data/gnome-wayland.desktop.in.in
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=GNOME
+Comment=This session logs you into GNOME
+Exec=@bindir@/gnome-session
+TryExec=@bindir@/gnome-session
+Type=Application
+DesktopNames=GNOME
diff --git a/data/meson.build b/data/meson.build
index b976e739..e6fbe424 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -88,6 +88,44 @@ install_data(
install_dir: join_paths(session_datadir, 'GConf', 'gsettings')
)
+unit_conf = configuration_data()
+unit_conf.set('libexecdir', session_libexecdir)
+
+# XXX: Once https://github.com/systemd/systemd/issues/9595 is fixed and we can
+# depend on this version, replace with something like:
+# dep_systemd = dependency('systemd', required: true)
+# systemd_userunitdir = dep_systemd.get_pkgconfig_variable('systemduserunitdir')
+# and uncomment systemd_dep below
+systemd_userunitdir = join_paths(session_prefix, 'lib', 'systemd', 'user')
+
+systemd_service = ['gnome-session-manager@.service',
+ 'gnome-session-ctl@.service',
+ 'gnome-session-failed.service']
+
+foreach service: systemd_service
+ configure_file(
+ input: service + '.in',
+ output: service,
+ install: true,
+ install_dir: systemd_userunitdir,
+ configuration: unit_conf
+ )
+endforeach
+
+systemd_target = files('gnome-session@.target',
+ 'gnome-session.target',
+ 'gnome-session-pre.target',
+ 'gnome-session-manager.target',
+ 'gnome-session-initialized.target',
+ 'gnome-session-shutdown.target',
+ 'gnome-session-failed.target',
+ )
+
+install_data(
+ systemd_target,
+ install_dir: systemd_userunitdir
+)
+
data = files('hardware-compatibility')
if enable_session_selector
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]