From b6da101d4d5ff66b17277818b023dc488ca59dff7123135d6f4f587add09dd08 Mon Sep 17 00:00:00 2001 From: OBS User unknown Date: Fri, 28 Nov 2008 14:53:14 +0000 Subject: [PATCH] OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/pulseaudio?expand=0&rev=39 --- pulseaudio.changes | 7 +++++ pulseaudio.spec | 6 +++- setup-pulseaudio | 74 +++++++++++++--------------------------------- 3 files changed, 33 insertions(+), 54 deletions(-) diff --git a/pulseaudio.changes b/pulseaudio.changes index c9458f8..e90861a 100644 --- a/pulseaudio.changes +++ b/pulseaudio.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Nov 24 11:42:43 CET 2008 - rodrigo@novell.com + +- Use /etc/alsa-pulse.conf for ALSA when enabling PulseAudio, as we + already do in GNOME, instead of touching /etc/alsa.conf +- Don't run the script if user is not root (bnc#445997) + ------------------------------------------------------------------- Wed Nov 19 13:14:25 CET 2008 - rodrigo@novell.com diff --git a/pulseaudio.spec b/pulseaudio.spec index 71602d8..75ae3df 100644 --- a/pulseaudio.spec +++ b/pulseaudio.spec @@ -22,7 +22,7 @@ Name: pulseaudio %define drvver 0.9 Summary: A Networked Sound Server Version: 0.9.12 -Release: 8 +Release: 9 License: GPL v2 or later; LGPL v2.1 or later Group: System/Sound Daemons Source: %{name}-%{version}.tar.bz2 @@ -548,6 +548,10 @@ groupadd -r pulse-access &>/dev/null || : %{_mandir}/man1/pax11publish.1.gz %changelog +* Mon Nov 24 2008 rodrigo@novell.com +- Use /etc/alsa-pulse.conf for ALSA when enabling PulseAudio, as we + already do in GNOME, instead of touching /etc/alsa.conf +- Don't run the script if user is not root (bnc#445997) * Wed Nov 19 2008 rodrigo@novell.com - Some fixes in setup-pulseaudio script (bnc#445015) * Wed Nov 19 2008 rodrigo@novell.com diff --git a/setup-pulseaudio b/setup-pulseaudio index 7a19087..a2a489d 100644 --- a/setup-pulseaudio +++ b/setup-pulseaudio @@ -9,60 +9,27 @@ show_help() { echo " --enable Enables PulseAudio" echo " --disable Disables PulseAudio" echo " --status Shows activation state (disabled or enabled) for PulseAudio" + echo "" + echo "You need to be root for this command to succeed" exit } +check_root() { + id=`id -u` + if [ "x$id" = "x0" ]; then + true + else + echo "You need to be root in order to enable/disable pulseaudio" + false + fi +} + enable_alsa() { echo "Enabling PulseAudio for ALSA..." - # Add PCM PA device - if test -f /etc/asound.conf; then - if grep pcm.pulse /etc/asound.conf; then - echo "pcm.pulse device already in /etc/asound.conf" - else - echo "" >> /etc/asound.conf - echo "pcm.pulse {" >> /etc/asound.conf - echo " type pulse" >> /etc/asound.conf - echo "}" >> /etc/asound.conf - fi - - # Add CTL PA device - if grep ctl.pulse /etc/asound.conf; then - echo "ctl.pulse device already in /etc/asound.conf" - else - echo "" >> /etc/asound.conf - echo "ctl.pulse {" >> /etc/asound.conf - echo " type pulse" >> /etc/asound.conf - echo "}" >> /etc/asound.conf - fi + if grep "ALSA_CONFIG_PATH" /etc/environment; then + echo "PulseAudio config for ALSA already in use" else - echo "" >> /etc/asound.conf - echo "pcm.pulse {" >> /etc/asound.conf - echo " type pulse" >> /etc/asound.conf - echo "}" >> /etc/asound.conf - - echo "" >> /etc/asound.conf - echo "ctl.pulse {" >> /etc/asound.conf - echo " type pulse" >> /etc/asound.conf - echo "}" >> /etc/asound.conf - fi - - # Now set the default devices - if grep "pcm.!default" /etc/asound.conf; then - echo "" - else - echo "" >> /etc/asound.conf - echo "pcm.!default {" >> /etc/asound.conf - echo " type pulse" >> /etc/asound.conf - echo "}" >> /etc/asound.conf - fi - - if grep "ctl.!default" /etc/asound.conf; then - echo "" - else - echo "" >> /etc/asound.conf - echo "ctl.!default {" >> /etc/asound.conf - echo " type pulse" >> /etc/asound.conf - echo "}" >> /etc/asound.conf + echo "ALSA_CONFIG_PATH=/etc/alsa-pulse.conf" >> /etc/environment fi } @@ -116,7 +83,7 @@ enable_sdl() { echo "Enabling PulseAudio for SDL..." # For SDL, we just add an environment variable, so that apps use the PA audio driver if grep SDL_AUDIODRIVER /etc/environment; then - sed s/SDL_AUDIODRIVER*/SDL_AUDIODRIVER=pulse /etc/environment + echo "SDL already setup to use PulseAudio" else echo "SDL_AUDIODRIVER=pulse" >> /etc/environment fi @@ -140,8 +107,7 @@ enable_xine() { disable_alsa() { echo "Disabling PulseAudio for ALSA..." - # FIXME: perl -pi -e ... - echo "" + perl -pi -e "s|ALSA_CONFIG_PATH=/etc/alsa-pulse.conf||g;" /etc/environment } disable_libao() { @@ -174,7 +140,7 @@ disable_oss() { disable_sdl() { echo "Disabling PulseAudio for SDL..." if grep "SDL_AUDIODRIVER=pulse" /etc/environment; then - sed s/SDL_AUDIODRIVER=pulse// /etc/environment + perl -pi -e "s|SDL_AUDIODRIVER=pulse||g;" /etc/environment fi } @@ -191,6 +157,7 @@ disable_xine() { case $1 in --enable) + check_root || exit ENABLE=1 enable_alsa enable_libao @@ -202,6 +169,7 @@ case $1 in enable_xine ;; --disable) + check_root || exit ENABLE=0 disable_alsa disable_libao @@ -241,4 +209,4 @@ else fi fi -/sbin/SuSEconfig \ No newline at end of file +/sbin/SuSEconfig