From e542e810041efef6497597ee55b4c7d5c349ba3e Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 17 Oct 2014 15:10:14 +0200 Subject: [PATCH] launch: Add systemd units for launching pulseaudio user instances --- 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 25cb207..23905ad 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 c037db7..a4a66c5 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 0000000..e08ff1e --- /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 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.7.4