summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-10-17 15:10:14 +0200
committerColin Guthrie <colin@mageia.org>2014-11-03 12:32:23 +0000
commite542e810041efef6497597ee55b4c7d5c349ba3e (patch)
tree177873af3587f65bcca0bdfb36049262a28df9c1
parent42156d2b5ac797e5f28f8d0d38b691053f3f6fc7 (diff)
downloadpulseaudio-e542e810041efef6497597ee55b4c7d5c349ba3e.tar.gz
launch: Add systemd units for launching pulseaudio user instances
-rw-r--r--configure.ac11
-rw-r--r--src/Makefile.am12
-rw-r--r--src/daemon/systemd/user/pulseaudio.service.in10
-rw-r--r--src/daemon/systemd/user/pulseaudio.socket10
4 files changed, 42 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 25cb20780..23905adf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1203,6 +1203,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"],
@@ -1458,6 +1465,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 c037db70c..a4a66c575 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-@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 #
###################################
@@ -2152,7 +2162,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 000000000..e08ff1efd
--- /dev/null
+++ b/src/daemon/systemd/user/pulseaudio.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Sound Service
+
+[Service]
+ExecStart=@PA_BINARY@ --daemonize=no
+Restart=on-failure
+
+[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 000000000..332ece893
--- /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