[PATCH 5/5] Add wayland.socket systemd unit for socket activation
Benjamin Franzke
benjaminfranzke at googlemail.com
Wed Feb 27 03:10:20 PST 2013
Wayland compositors aiming for systemd socket activation
should use wayland.socket in Sockets= in its service files units.
This way they get automatically systemd socket activation.
The unit is installed as a user unit, so intended to be used is a
systemd user session. This is for the reason of being able provide
general service files for compositors, e.g. not needing to set a custom
User= or Environmnet=DISPLAY=:0 or so..
In theory it could be used for a system session as well.
FIXME: The unit is installed as suggestend by systemd:man:daemon(7).
This has the drawback that if wayland is installed in a user prefix
and no custom --with-systemduserunitdir is passed to configure,
the build system tries to install to e.g. /usr/lib/systemd/user
which may be an access violation.
Maybe it should be explicitly enabled to install the unit?
---
Makefile.am | 3 +++
configure.ac | 8 ++++++++
src/Makefile.am | 6 +++++-
src/wayland.socket | 15 +++++++++++++++
4 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 src/wayland.socket
diff --git a/Makefile.am b/Makefile.am
index 306d7b3..1b6cdd7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,3 +10,6 @@ aclocaldir = $(datadir)/aclocal
aclocal_DATA = wayland-scanner.m4 wayland-scanner.mk
EXTRA_DIST = wayland-scanner.mk
+DISTCHECK_CONFIGURE_FLAGS = \
+ --with-systemduserunitdir=$$dc_install_base/$(systemduserunitdir)
+
diff --git a/configure.ac b/configure.ac
index 883411c..1f60ffc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,14 @@ if test "x$enable_scanner" = "xyes"; then
AC_SUBST(EXPAT_LIBS)
fi
+AC_ARG_WITH([systemduserunitdir],
+ AS_HELP_STRING([--with-systemduserunitdir=<dir>], [Directory for systemd user service files]),
+ [], [with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)])
+if test "x$with_systemdusersystemunitdir" != xno; then
+ AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
+fi
+AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno ])
+
AC_PATH_PROG(XSLTPROC, xsltproc)
AM_CONDITIONAL([HAVE_XSLTPROC], [test "x$XSLTPROC" != "x"])
diff --git a/src/Makefile.am b/src/Makefile.am
index b62de56..f900cc2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,6 +37,10 @@ libwayland_client_la_SOURCES = \
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = wayland-client.pc wayland-server.pc
+if HAVE_SYSTEMD
+systemduserunit_DATA = wayland.socket
+endif
+
AM_CPPFLAGS = $(FFI_CFLAGS)
AM_CFLAGS = $(GCC_CFLAGS)
@@ -68,4 +72,4 @@ BUILT_SOURCES = \
CLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = wayland-version.h
-EXTRA_DIST = wayland-version.h.in
+EXTRA_DIST = wayland-version.h.in wayland.socket
diff --git a/src/wayland.socket b/src/wayland.socket
new file mode 100644
index 0000000..b2633b3
--- /dev/null
+++ b/src/wayland.socket
@@ -0,0 +1,15 @@
+[Unit]
+Description=Wayland Socket
+
+[Socket]
+ListenStream=%t/wayland-0
+
+# The default wayland compositor should make wayland.service a
+# symlink to itself, so that this socket activates the right
+# acutal wayland compositor.
+
+# Best way to achieve that is by adding this to your unit file
+# (i.e. to weston.service):
+#
+# [Install]
+# Alias=wayland.service
--
1.7.12.4
More information about the wayland-devel
mailing list