[gnome-session/wip/laney/systemd-user-switch: 2/3] Add systemd user units



commit 215e654c5a7624719771f58bf6a9b6d3a6c2007b
Author: Iain Lane <iainl gnome org>
Date:   Wed Jul 4 12:15:29 2018 +0100

    Add systemd user units
    
    The structure is like this:
    
      - gnome-session-wayland.target, gnome-session-x11.target: Top-level
        targets launched directly to start the regular GNOME (Shell) session
        for wayland or x11 respectively.
      - gnome-session@.service: Execute gnome-session-binary tself for the
        specified (template) session. Is active once
        org.gnome.SessionManager is claimed on the bus.
      - gnome-session-bus.target: Bound to gnome-session@.service - if
        something needs to start after any instance of gnome-session@
        starts, it can be After= this one. gnome-settings-daemon uses this.
    
    We also split out gnome-wayland.desktop.in, as it is going to need to
    launch gnome-session-wayland.target.

 data/gnome-session-bus.target     |  3 +++
 data/gnome-session-wayland.target |  8 ++++++
 data/gnome-session-x11.target     |  8 ++++++
 data/gnome-session  service in    | 11 ++++++++
 data/gnome-wayland.desktop.in.in  |  7 ++++++
 data/meson.build                  | 53 +++++++++++++++++++++++++--------------
 meson_post_install.py             |  9 ++-----
 7 files changed, 73 insertions(+), 26 deletions(-)
---
diff --git a/data/gnome-session-bus.target b/data/gnome-session-bus.target
new file mode 100644
index 00000000..425c1571
--- /dev/null
+++ b/data/gnome-session-bus.target
@@ -0,0 +1,3 @@
+[Unit]
+Description=gnome-session is on the bus
+StopWhenUnneeded=yes
diff --git a/data/gnome-session-wayland.target b/data/gnome-session-wayland.target
new file mode 100644
index 00000000..7a477e35
--- /dev/null
+++ b/data/gnome-session-wayland.target
@@ -0,0 +1,8 @@
+[Unit]
+Description=User systemd services for the GNOME graphical session (wayland)
+Requires=graphical-session-pre.target
+# start/tear down graphical-session.target along with the gnome session
+BindsTo=graphical-session.target
+# session leader -- if this dies, die along with it
+BindsTo=gnome-session@gnome.service
+Wants=gnome-settings-daemon-wayland.target gnome-shell-wayland.target
diff --git a/data/gnome-session-x11.target b/data/gnome-session-x11.target
new file mode 100644
index 00000000..c3c1bdb5
--- /dev/null
+++ b/data/gnome-session-x11.target
@@ -0,0 +1,8 @@
+[Unit]
+Description=User systemd services for the GNOME graphical session (x11)
+Requires=graphical-session-pre.target
+# start/tear down graphical-session.target along with the gnome session
+BindsTo=graphical-session.target
+# session leader -- if this dies, die along with it
+BindsTo=gnome-session@gnome.service
+Wants=gnome-settings-daemon-x11.target gnome-shell-x11.target
diff --git a/data/gnome-session  service in b/data/gnome-session  service in
new file mode 100644
index 00000000..bafce9fd
--- /dev/null
+++ b/data/gnome-session  service in
@@ -0,0 +1,11 @@
+[Unit]
+Description=GNOME Session Manager (%i session)
+PartOf=graphical-session.target
+After=graphical-session-pre.target
+Before=gnome-settings-daemon.target gnome-session-bus.target
+BindsTo=gnome-session-bus.target
+
+[Service]
+Type=dbus
+ExecStart=@libexecdir@/gnome-session-binary --ignore-required-components --session=%i
+BusName=org.gnome.SessionManager
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..372ef8c4 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,19 +1,22 @@
-desktop_plain = 'gnome'
-
+# We'd like to have gnome-wayland have output: 'gnome.desktop', but this
+# doesn't work https://github.com/mesonbuild/meson/issues/3759 So this is later
+# renamed in meson_post_install.py
 desktops = [
-  desktop_plain,
-  'gnome-xorg'
+  ['gnome',        'xsessions'],
+  ['gnome-xorg',   'xsessions'],
+  ['gnome-wayland', 'wayland-sessions']
 ]
 
 if enable_session_selector
-  desktops += 'gnome-custom-session'
+  desktops += ['gnome-custom-session', 'xsessions']
 endif
 
 foreach name: desktops
   desktop_conf = configuration_data()
   desktop_conf.set('bindir', session_bindir)
 
-  desktop = name + '.desktop'
+  desktop = name[0] + '.desktop'
+  dir = name[1]
 
   desktop_in = configure_file(
     input: desktop + '.in.in',
@@ -21,25 +24,14 @@ foreach name: desktops
     configuration: desktop_conf
   )
 
-  install_dir = join_paths(session_datadir, 'xsessions')
-  # FIXME: The same target can not be copied into two directories.
-  #        There is a workaround in meson_post_install.py until proper solution arises:
-  #        https://groups.google.com/forum/#!topic/mesonbuild/3iIoYPrN4P0
-  if name == desktop_plain
-    #install_dir: [
-    #  join_paths(session_datadir, 'xsessions'),
-    #  join_paths(session_datadir, 'wayland-sessions')
-    #]
-  endif
-
-  desktop_target = i18n.merge_file(
+  i18n.merge_file(
     desktop,
     type: 'desktop',
     input: desktop_in,
     output: desktop,
     po_dir: po_dir,
     install: true,
-    install_dir: install_dir
+    install_dir: join_paths(session_datadir, dir)
   )
 endforeach
 
@@ -88,6 +80,29 @@ 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_userunitdir = dep_systemd.get_pkgconfig_variable('systemduserunitdir')
+
+configure_file(
+  input: 'gnome-session  service in',
+  output: 'gnome-session@.service',
+  install: true,
+  install_dir: systemd_userunitdir,
+  configuration: unit_conf
+)
+
+systemd_target = files('gnome-session-bus.target',
+                       'gnome-session-wayland.target',
+                       'gnome-session-x11.target')
+
+install_data(
+  systemd_target,
+  install_dir: systemd_userunitdir
+)
+
 data = files('hardware-compatibility')
 
 if enable_session_selector
diff --git a/meson_post_install.py b/meson_post_install.py
index e2e352cc..998277a9 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -15,12 +15,7 @@ if not os.environ.get('DESTDIR'):
   print('Compile gsettings schemas...')
   subprocess.call(['glib-compile-schemas', schemadir])
 
-# FIXME: this is due to unable to copy a generated target file:
-#        https://groups.google.com/forum/#!topic/mesonbuild/3iIoYPrN4P0
 dst_dir = os.path.join(install_root, 'wayland-sessions')
-if not os.path.exists(dst_dir):
-  os.makedirs(dst_dir)
 
-src = os.path.join(install_root, 'xsessions', 'gnome.desktop')
-dst = os.path.join(dst_dir, 'gnome.desktop')
-shutil.copyfile(src, dst)
+os.rename(os.path.join(dst_dir, 'gnome-wayland.desktop'),
+          os.path.join(dst_dir, 'gnome.desktop'))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]