[gnome-shell/wip/laney/systemd-user-units: 7/7] Add systemd units



commit e1c7401245a3408a357fad433c0feafd2589d87e
Author: Iain Lane <iain orangesquash org uk>
Date:   Wed Jan 17 15:56:17 2018 +0000

    Add systemd units
    
    So that we can be started by systemd --user, instead of gnome-session.
    
    There are three units:
    
      - gnome-shell.service: Start gnome-shell itself.
      - gnome-shell-x11.target, gnome-shell-wayland.target: Sync points for
        units that need to care if x11 or wayland is in use.
        gnome-settings-daemon will use these, for example.

 data/gnome-shell-wayland.target |  5 +++++
 data/gnome-shell-x11.target     |  5 +++++
 data/gnome-shell.service.in     | 11 +++++++++++
 data/meson.build                | 21 +++++++++++++++++++++
 meson.build                     |  8 +++++---
 src/meson.build                 |  2 +-
 6 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/data/gnome-shell-wayland.target b/data/gnome-shell-wayland.target
new file mode 100644
index 000000000..a75da3ec7
--- /dev/null
+++ b/data/gnome-shell-wayland.target
@@ -0,0 +1,5 @@
+[Unit]
+Description=GNOME Shell (wayland sync point)
+After=gnome-shell.service
+BindsTo=gnome-shell.service
+Conflicts=gnome-shell-x11.target
diff --git a/data/gnome-shell-x11.target b/data/gnome-shell-x11.target
new file mode 100644
index 000000000..4da13509c
--- /dev/null
+++ b/data/gnome-shell-x11.target
@@ -0,0 +1,5 @@
+[Unit]
+Description=GNOME Shell (x11 sync point)
+After=gnome-shell.service
+BindsTo=gnome-shell.service
+Conflicts=gnome-shell-wayland.target
diff --git a/data/gnome-shell.service.in b/data/gnome-shell.service.in
new file mode 100644
index 000000000..ee275fa0e
--- /dev/null
+++ b/data/gnome-shell.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=GNOME Shell
+Wants=gnome-session.service
+After=graphical-session-pre.target gnome-session-bus.target
+PartOf=graphical-session.target
+
+[Service]
+Type=dbus
+ExecStart=@bindir@/gnome-shell
+Restart=on-failure
+BusName=org.gnome.Shell
diff --git a/data/meson.build b/data/meson.build
index 7c9807721..163884bb6 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -93,6 +93,27 @@ schema = configure_file(
   install_dir: schemadir
 )
 
+unitconf = configuration_data()
+unitconf.set('bindir', bindir)
+
+if have_systemd
+  systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
+else
+  systemduserunitdir = join_paths(libdir, 'systemd', 'user')
+endif
+
+unit = configure_file(
+  input: 'gnome-shell.service.in',
+  output: 'gnome-shell.service',
+  configuration: unitconf,
+  install_dir: systemduserunitdir
+)
+
+units = files('gnome-shell-wayland.target',
+              'gnome-shell-x11.target')
+
+install_data(units, install_dir: systemduserunitdir)
+
 # for unit tests - gnome.compile_schemas() only looks in srcdir
 custom_target('compile-schemas',
   input: schema,
diff --git a/meson.build b/meson.build
index 9f7384fe3..479f4edfa 100644
--- a/meson.build
+++ b/meson.build
@@ -117,10 +117,12 @@ else
 endif
 
 if get_option('systemd')
-  systemd_dep = dependency('libsystemd')
+  libsystemd_dep = dependency('libsystemd')
+  systemd_dep = dependency('systemd')
+  have_libsystemd = libsystemd_dep.found()
   have_systemd = systemd_dep.found()
 else
-  systemd_dep = []
+  libsystemd_dep = []
   have_systemd = false
 endif
 
@@ -150,7 +152,7 @@ cdata.set_quoted('VERSION', meson.project_version())
 cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
 
 cdata.set('HAVE_NETWORKMANAGER', have_networkmanager)
-cdata.set('HAVE_SYSTEMD', have_systemd)
+cdata.set('HAVE_SYSTEMD', have_libsystemd)
 
 cdata.set('HAVE_FDWALK', cc.has_function('fdwalk'))
 cdata.set('HAVE_MALLINFO', cc.has_function('mallinfo'))
diff --git a/src/meson.build b/src/meson.build
index 1d655f407..2670f589c 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -53,7 +53,7 @@ gnome_shell_deps = [
   canberra_dep, canberra_gtk_dep,
   polkit_dep,
   gcr_dep,
-  systemd_dep
+  libsystemd_dep
 ]
 
 gnome_shell_deps += nm_deps


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