#!/bin/sh

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.

set -e

[ -z "$PULSE_SERVER" ]

# Some Mandriva customisations
CONFIG=/etc/sound/profiles/current/profile.conf

PULSE_ARGS=" --log-target=syslog"
[ -r "$CONFIG" ] && . $CONFIG

if [ "$SOUNDPROFILE" != "pulse" ]; then
  echo "Pulseaudio startup disabled due to soundprofile configuration" >&2
else

/usr/bin/pulseaudio --start ${PULSE_ARGS} "$@"

# End Mandriva customisations (except for the "fi" below)

if [ x"$DISPLAY" != x ] ; then

    /usr/bin/pactl load-module module-x11-publish "display=$DISPLAY" > /dev/null
    #/usr/bin/pactl load-module module-x11-cork-request "display=$DISPLAY" > /dev/null

    if [ x"$SESSION_MANAGER" != x ] ; then
	/usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null
    fi
fi

fi
