2011-04-27 19:57:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# sound - sound configuration plugin for postplug
|
|
|
|
# Copyright (c) 2005-2007 by Davide Madrisan <davide.madrisan@gmail.com>
|
2011-11-06 23:40:58 +01:00
|
|
|
# Copyright (c) 2005-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
2011-04-27 19:57:03 +02:00
|
|
|
|
|
|
|
# Note: Some code has been stolen from /usr/sbin/alsaconf version 1.0.13
|
|
|
|
|
|
|
|
if [ $UID != 0 ]; then
|
|
|
|
echo "$0: must be superuser." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
me="sound"
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/machine ] && . /etc/sysconfig/machine
|
|
|
|
|
|
|
|
. /etc/postplug/postplug.defs
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/postplug ] && . /etc/sysconfig/postplug
|
|
|
|
|
|
|
|
SYSCONFIG_SOUNDCARDS=/etc/sysconfig/soundcards
|
|
|
|
|
2011-11-06 23:46:42 +01:00
|
|
|
[ -e /etc/asound.state ] && rm -f /etc/asound.state
|
|
|
|
|
2011-04-27 19:57:03 +02:00
|
|
|
# set default mixer volumes
|
|
|
|
function set_mixers() {
|
|
|
|
[ -x /usr/bin/amixer ] || return
|
|
|
|
|
|
|
|
/usr/bin/amixer -s -q <<_EOF
|
|
|
|
set Master 90% unmute
|
|
|
|
set 'Master Mono' 75% unmute
|
|
|
|
set Front 90% unmute
|
|
|
|
set Speaker 90% unmute
|
|
|
|
set PCM 90% unmute
|
|
|
|
mixer Synth 90% unmute
|
|
|
|
mixer CD 90% unmute
|
|
|
|
# mute mic
|
|
|
|
set Mic 0% mute
|
|
|
|
# ESS 1969 chipset has 2 PCM channels
|
|
|
|
set PCM,1 90% unmute
|
|
|
|
# Trident/YMFPCI/emu10k1
|
|
|
|
set Wave 100% unmute
|
|
|
|
set Music 100% unmute
|
|
|
|
set AC97 100% unmute
|
|
|
|
# CS4237B chipset:
|
|
|
|
set 'Master Digital' 75% unmute
|
|
|
|
# Envy24 chips with analog outs
|
|
|
|
set DAC 90% unmute
|
|
|
|
set DAC,0 90% unmute
|
|
|
|
set DAC,1 90% unmute
|
|
|
|
# some notebooks use headphone instead of master
|
|
|
|
set Headphone 75% unmute
|
|
|
|
set Playback 100% unmute
|
|
|
|
# turn off digital switches
|
|
|
|
set "SB Live Analog/Digital Output Jack" off
|
|
|
|
set "Audigy Analog/Digital Output Jack" off
|
|
|
|
_EOF
|
|
|
|
}
|
|
|
|
|
2011-11-06 23:40:58 +01:00
|
|
|
SOUND_DEV="`lspci -n | grep " 04[0-9][0-9]: "`"
|
2011-04-27 19:57:03 +02:00
|
|
|
|
2011-11-06 23:40:58 +01:00
|
|
|
if [ "$SOUND_FORCE_RESCAN" != "on" -a "$SOUND_FORCE_RESCAN" != "1" ]; then
|
|
|
|
if [ -e $postpluglibdir/sound.cache ]; then
|
|
|
|
SOUND_DEV_CACHED="`cat $postpluglibdir/sound.cache`"
|
|
|
|
[ "$SOUND_DEV" = "$SOUND_DEV_CACHED" ] && exit 0
|
|
|
|
logmsg "$me" "warning: audio device appears to have changed; re-probing"
|
|
|
|
mv $SYSCONFIG_SOUNDCARDS $SYSCONFIG_SOUNDCARDS.postplug.save
|
2011-04-27 19:57:03 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-11-06 23:40:58 +01:00
|
|
|
echo "$SOUND_DEV" > $postpluglibdir/sound.cache
|
|
|
|
for c in /proc/asound/card[0-9]*; do
|
|
|
|
id=`cat $c/id`
|
|
|
|
codec=`grep Codec: $c/codec* | head -n1`
|
|
|
|
logmsg "$me" $"setting volumes for $id sound card ($codec)"
|
|
|
|
index=${d1/*card}
|
|
|
|
set_mixers $index
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -x /usr/sbin/alsactl ]; then
|
|
|
|
logmsg "$me" $"saving the mixer setup (/var/lib/sound/asound.state)"
|
|
|
|
/usr/sbin/alsactl store >/dev/null
|
2011-04-27 19:57:03 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$SOUND_DEV" > $postpluglibdir/sound.cache
|
|
|
|
|
|
|
|
exit 0
|