[pulseaudio-discuss] [PATCH 6/8] launch: Add systemd units for launching pulseaudio user instances

Colin Guthrie colin at mageia.org
Sat Oct 18 11:43:29 PDT 2014


---
 configure.ac                                  | 11 +++++++++++
 src/Makefile.am                               | 12 +++++++++++-
 src/daemon/systemd/user/pulseaudio.service.in | 10 ++++++++++
 src/daemon/systemd/user/pulseaudio.socket     | 10 ++++++++++
 4 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 src/daemon/systemd/user/pulseaudio.service.in
 create mode 100644 src/daemon/systemd/user/pulseaudio.socket

diff --git a/configure.ac b/configure.ac
index 3a249d0..6c9690f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1199,6 +1199,13 @@ AS_IF([test "x$HAVE_SYSTEMD" = "x1"],
         HAVE_SYSTEMD_JOURNAL=1
     ])
 
+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_systemduserunitdir" != xno; then
+        AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
+fi
+
 #### systemd daemon support (optional) ####
 
 AS_IF([test "x$enable_systemd_daemon" != "xno"],
@@ -1455,6 +1462,10 @@ AC_CONFIG_FILES([src/default.pa:src/daemon/default.pa.in],
     [m4 src/default.pa > src/default.pa.gen && mv src/default.pa.gen src/default.pa])
 AC_CONFIG_FILES([src/system.pa:src/daemon/system.pa.in],
     [m4 src/system.pa > src/system.pa.gen && mv src/system.pa.gen src/system.pa])
+AS_IF([test "$HAVE_SYSTEMD_DAEMON" = "x1"],
+    [
+        AC_CONFIG_FILES([src/pulseaudio.service:src/daemon/systemd/user/pulseaudio.service.in])
+    ])
 
 # CMake related ProjectConfig files
 PA_LIBDIR="$libdir"
diff --git a/src/Makefile.am b/src/Makefile.am
index 20e5f4f..717af63 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,6 +95,8 @@ EXTRA_DIST = \
 		depmod.py \
 		daemon/esdcompat.in \
 		daemon/start-pulseaudio-x11.in \
+		daemon/systemd/user/pulseaudio.service.in \
+		daemon/systemd/user/pulseaudio.socket \
 		utils/padsp.in \
 		utils/qpaeq \
 		modules/module-defs.h.m4 \
@@ -217,6 +219,14 @@ pax11publish_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
 pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINOR@.la $(X11_LIBS)
 pax11publish_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
+if HAVE_SYSTEMD_DAEMON
+
+systemduserunit_DATA = \
+    pulseaudio.service \
+    daemon/systemd/user/pulseaudio.socket
+
+endif
+
 ###################################
 #         Test programs           #
 ###################################
@@ -2153,7 +2163,7 @@ module_rygel_media_server_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 ###################################
 
 CLEANFILES += daemon/pulseaudio.desktop
-DISTCLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11
+DISTCLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11 pulseaudio.service
 
 if OS_IS_WIN32
 SYMLINK_PROGRAM=cd $(DESTDIR)$(bindir) && cp
diff --git a/src/daemon/systemd/user/pulseaudio.service.in b/src/daemon/systemd/user/pulseaudio.service.in
new file mode 100644
index 0000000..a941c54
--- /dev/null
+++ b/src/daemon/systemd/user/pulseaudio.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Sound Service
+
+[Service]
+ExecStart=@PA_BINARY@
+Restart=always
+
+[Install]
+Also=pulseaudio.socket
+WantedBy=default.target
diff --git a/src/daemon/systemd/user/pulseaudio.socket b/src/daemon/systemd/user/pulseaudio.socket
new file mode 100644
index 0000000..332ece8
--- /dev/null
+++ b/src/daemon/systemd/user/pulseaudio.socket
@@ -0,0 +1,10 @@
+[Unit]
+Description=Sound System
+
+[Socket]
+Priority=6
+Backlog=5
+ListenStream=%t/pulse/native
+
+[Install]
+WantedBy=sockets.target
-- 
2.1.2



More information about the pulseaudio-discuss mailing list