From 786b4b05dc1bfc725995f4c2556d49aec5e2ae1b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Feb 2011 22:35:00 +0100 Subject: systemd: add unit for bootup and shutdown sounds --- .gitignore | 3 +++ Makefile.am | 5 ++++- configure.ac | 13 +++++++++++++ src/Makefile.am | 22 +++++++++++++++++++++- src/canberra-system-bootup.service.in | 18 ++++++++++++++++++ src/canberra-system-shutdown-reboot.service.in | 17 +++++++++++++++++ src/canberra-system-shutdown.service.in | 16 ++++++++++++++++ src/oss.c | 3 --- 8 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 src/canberra-system-bootup.service.in create mode 100644 src/canberra-system-shutdown-reboot.service.in create mode 100644 src/canberra-system-shutdown.service.in diff --git a/.gitignore b/.gitignore index 9efa773..af12cc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +src/canberra-system-bootup.service +src/canberra-system-shutdown-reboot.service +src/canberra-system-shutdown.service libcanberra-gtk3.pc README Makefile diff --git a/Makefile.am b/Makefile.am index bc36f32..ffa7265 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,7 +66,10 @@ else install-data-local: endif -DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc +DISTCHECK_CONFIGURE_FLAGS = \ + --enable-gtk-doc \ + --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) + ACLOCAL_AMFLAGS = -I m4 README: diff --git a/configure.ac b/configure.ac index 4d1376c..a6966da 100644 --- a/configure.ac +++ b/configure.ac @@ -502,6 +502,18 @@ if test "x${HAVE_CACHE}" = x1 ; then AC_DEFINE([HAVE_CACHE], 1, [Do cacheing?]) fi +# +# systemd +# +AC_ARG_WITH([systemdsystemunitdir], + AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), + [], + [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]) +if test "x$with_systemdsystemunitdir" != xno; then + AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) +fi +AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) + ### LYNX documentation generation ### AC_ARG_ENABLE([lynx], @@ -769,6 +781,7 @@ echo " Enable GTK3+: ${ENABLE_GTK3} GTK3 Modules Directory: ${GTK3_MODULES_DIR} Enable udev: ${ENABLE_UDEV} + systemd Unit Directory: ${with_systemdsystemunitdir} " diff --git a/src/Makefile.am b/src/Makefile.am index 48c75ba..d6a5352 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -274,6 +274,7 @@ endif endif bin_PROGRAMS = +CLEANFILES = if HAVE_UDEV if HAVE_ALSA @@ -291,6 +292,25 @@ canberra_boot_LDADD = \ canberra_boot_CFLAGS = \ $(UDEV_CFLAGS) +if HAVE_SYSTEMD + +systemdsystemunit_DATA = \ + canberra-system-bootup.service \ + canberra-system-shutdown.service \ + canberra-system-shutdown-reboot.service + +EXTRA_DIST += \ + canberra-system-bootup.service.in \ + canberra-system-shutdown.service.in \ + canberra-system-shutdown-reboot.service.in + +%.service: %.service.in + $(AM_V_GEN)sed -e 's,@bindir\@,$(bindir),g' $< > $@ + +CLEANFILES += \ + $(systemdsystemunit_DATA) + +endif endif endif @@ -415,7 +435,7 @@ gdmautostart_DATA = \ gnomeshutdown_SCRIPTS = \ libcanberra-logout-sound.sh -CLEANFILES = \ +CLEANFILES += \ libcanberra-login-sound.desktop \ libcanberra-ready-sound.desktop \ libcanberra-logout-sound.sh diff --git a/src/canberra-system-bootup.service.in b/src/canberra-system-bootup.service.in new file mode 100644 index 0000000..490b6b8 --- /dev/null +++ b/src/canberra-system-bootup.service.in @@ -0,0 +1,18 @@ +[Unit] +Description=Play Bootup Sound +DefaultDependencies=no +After=alsa-restore.service +Before=shutdown.target +Conflicts=shutdown.target + +# A little optimization under the assumption that we are using the +# standard freedesktop theme +ConditionPathExists=/usr/share/sounds/freedesktop/stereo/system-bootup.oga + +[Service] +Type=oneshot +ExecStart=-@bindir@/canberra-boot system-bootup + +[Install] +WantedBy=sound.target +Also=canberra-system-shutdown.service canberra-system-shutdown-reboot.service diff --git a/src/canberra-system-shutdown-reboot.service.in b/src/canberra-system-shutdown-reboot.service.in new file mode 100644 index 0000000..0e46765 --- /dev/null +++ b/src/canberra-system-shutdown-reboot.service.in @@ -0,0 +1,17 @@ +[Unit] +Description=Play Reboot Sound +DefaultDependencies=no +Before=shutdown.target + +# A little optimization under the assumption that we are using the +# standard freedesktop theme +ConditionPathExists=/usr/share/sounds/freedesktop/stereo/system-shutdown.oga +ConditionPathExists=/usr/share/sounds/freedesktop/stereo/system-shutdown-reboot.oga + +[Service] +Type=oneshot +ExecStart=-@bindir@/canberra-boot system-shutdown-reboot + +[Install] +WantedBy=reboot.target kexec.target +Also=canberra-system-shutdown.service diff --git a/src/canberra-system-shutdown.service.in b/src/canberra-system-shutdown.service.in new file mode 100644 index 0000000..f5ce0ca --- /dev/null +++ b/src/canberra-system-shutdown.service.in @@ -0,0 +1,16 @@ +[Unit] +Description=Play Shutdown Sound +DefaultDependencies=no +Before=shutdown.target + +# A little optimization under the assumption that we are using the +# standard freedesktop theme +ConditionPathExists=/usr/share/sounds/freedesktop/stereo/system-shutdown.oga + +[Service] +Type=oneshot +ExecStart=-@bindir@/canberra-boot system-shutdown + +[Install] +WantedBy=halt.target poweroff.target +Also=canberra-system-shutdown-reboot.service canberra-system-shutdown-reboot.service diff --git a/src/oss.c b/src/oss.c index 222503c..9bb7149 100644 --- a/src/oss.c +++ b/src/oss.c @@ -230,7 +230,6 @@ static int translate_error(int error) { } static int open_oss(ca_context *c, struct outstanding *out) { - struct private *p; int mode, val, test, ret; ca_return_val_if_fail(c, CA_ERROR_INVALID); @@ -241,8 +240,6 @@ static int open_oss(ca_context *c, struct outstanding *out) { * multichannel streams. We cannot support those files hence */ ca_return_val_if_fail(ca_sound_file_get_nchannels(out->file) <= 2, CA_ERROR_NOTSUPPORTED); - p = PRIVATE(c); - if ((out->pcm = open(c->device ? c->device : "/dev/dsp", O_WRONLY | O_NONBLOCK, 0)) < 0) goto finish_errno; -- cgit