Several methods exist to load and save sound card settings under linux. Since I wanted a non-gui method of setting the sound card's properties I found that the asound tool does exactly that. The nameing of the various controls and registers will probably be different for every sound card so check with 'amixer controls' what those registers are called before running this script.
#!/bin/sh # pre-sets sound device mixer controls # find out which controls are available by issuing 'amixer controls' ACTL=/usr/sbin/alsactl AMIX=/usr/bin/amixer HWDEV=0 #load some defaults #$ACTL -f /etc/asound.state restore # Set the default recording channel $AMIX -c $HWDEV sset 'PCM Capture Source' 'Mixer' # Set the input level for PCM to 80%: $AMIX -c $HWDEV set PCM 80% # Set the input level for LINE to 0%: $AMIX -c $HWDEV set Line 0% # Set the playback level for LINE to 55%: $AMIX -c $HWDEV set Line 55% # Unmute the Line playback $AMIX -c $HWDEV set Line unmute # set all playback levels to 0% except the Front-Left and Front-Right channels (10%) $AMIX cset numid=7 38,38,0,0,0,0,0,0 # force loading of these settings as otherwise it takes about 3 minutes.. sleep 5 /usr/bin/alsamixer > /dev/null 2>&1 & sleep 5 /usr/bin/killall alsamixer > /dev/null 2>&1
Please note that the volume levels when not listed in per cent they are not 0 - 100 or 0 - 255. Check the 'amixer controls' output for this.