a26a765
#!/bin/bash
a26a765
a26a765
SCRIPT_VERSION=0.4.41
a26a765
CHANGELOG="http://hg.alsa-project.org/alsa/log/tip/alsa-info.sh"
a26a765
a26a765
#################################################################################
a26a765
#Copyright (C) 2007 Free Software Foundation.
a26a765
a26a765
#This program is free software; you can redistribute it and/or modify
a26a765
#it under the terms of the GNU General Public License as published by
a26a765
#the Free Software Foundation; either version 2 of the License, or
a26a765
#(at your option) any later version.
a26a765
a26a765
#This program is distributed in the hope that it will be useful,
a26a765
#but WITHOUT ANY WARRANTY; without even the implied warranty of
a26a765
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a26a765
#GNU General Public License for more details.
a26a765
a26a765
#You should have received a copy of the GNU General Public License
a26a765
#along with this program; if not, write to the Free Software
a26a765
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
a26a765
a26a765
##################################################################################
a26a765
a26a765
#The script was written for 2 main reasons:
a26a765
# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user.
a26a765
# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them.
a26a765
a26a765
#Change the PATH variable, so we can run lspci (needed for some distros)
a26a765
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin
a26a765
BGTITLE="ALSA-Info v $SCRIPT_VERSION"
a26a765
PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
a26a765
#Define some simple functions
a26a765
a26a765
update() {
a26a765
	wget -O /tmp/alsa-info.sh http://hg.alsa-project.org/alsa/raw-file/tip/alsa-info.sh >/dev/null 2>&1
a26a765
	REMOTE_VERSION=`grep SCRIPT_VERSION /tmp/alsa-info.sh |head -n1 |sed 's/.*=//'`
a26a765
	if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
a26a765
		if [[ -n $DIALOG ]]
a26a765
		then
a26a765
			dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to install it?" 0 0
a26a765
			DIALOG_EXIT_CODE=$?
a26a765
			if [[ $DIALOG_EXIT_CODE = 0 ]]
a26a765
			then
a26a765
				cp /tmp/alsa-info.sh $0
a26a765
				echo "ALSA-Info script has been updated to v $REMOTE_VERSION"
a26a765
				echo "To view the ChangeLog, please visit $CHANGELOG"
a26a765
				echo "Please re-run the script"
a26a765
				exit
a26a765
			fi
a26a765
		else
a26a765
			cp /tmp/alsa-info.sh $0
a26a765
			echo "Newer version detected: $REMOTE_VERSION"
a26a765
			echo "To view the ChangeLog, please visit $CHANGELOG"
a26a765
			echo "ALSA-Info script has been updated. Please re-run it."
a26a765
a26a765
			exit
a26a765
		fi
a26a765
	fi
a26a765
	rm /tmp/alsa-info.sh 2>/dev/null
a26a765
}
a26a765
a26a765
cleanup() {
a26a765
	rm -r $TEMPDIR 2>/dev/null
a26a765
}
a26a765
a26a765
a26a765
#### FIX ME
a26a765
withsecure() {
a26a765
	POST_URL="http://alsa-info.pastebin.ca"
a26a765
}
a26a765
###########
a26a765
a26a765
withaplay() {
a26a765
        echo "!!Aplay/Arecord output" >> $FILE
a26a765
        echo "!!------------" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
       	echo "APLAY" >> $FILE
a26a765
	echo "" >> $FILE 
a26a765
	aplay -l >> $FILE
a26a765
        echo "" >> $FILE
a26a765
       	echo "ARECORD" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	arecord -l >> $FILE 
a26a765
	echo "" >> $FILE
a26a765
}
a26a765
a26a765
withlsmod() {
a26a765
	echo "!!All Loaded Modules" >> $FILE
a26a765
	echo "!!------------------" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	lsmod |awk {'print $1'} >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
}
a26a765
a26a765
withamixer() {
a26a765
        echo "!!Amixer output" >> $FILE
a26a765
        echo "!!-------------" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
	for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do
a26a765
	CARD_NAME=`grep "^ *$i " /tmp/alsainfo/alsacards.tmp|awk {'print $2'}`
a26a765
	echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE
a26a765
	echo "" >>$FILE
a26a765
	amixer -c$i>> $FILE
a26a765
        echo "" >> $FILE
a26a765
	done
a26a765
	echo "" >> $FILE
a26a765
}
a26a765
a26a765
withalsactl() {
a26a765
	echo "!!Alsactl output" >> $FILE
a26a765
        echo "!!-------------" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
        exe=""
a26a765
        if [ -x /usr/sbin/alsactl ]; then
a26a765
        	exe="/usr/sbin/alsactl"
a26a765
        fi
a26a765
        if [ -x /usr/local/sbin/alsactl ]; then
a26a765
        	exe="/usr/local/sbin/alsactl"
a26a765
        fi
a26a765
        if [ -z "$exe" ]; then
a26a765
        	exe=`whereis alsactl | cut -d ' ' -f 2`
a26a765
        fi
a26a765
	$exe -f /tmp/alsainfo/alsactl.tmp store
a26a765
	echo "--startcollapse--" >> $FILE
a26a765
	cat /tmp/alsainfo/alsactl.tmp >> $FILE
a26a765
	echo "--endcollapse--" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
}
a26a765
a26a765
withdevices() {
a26a765
        echo "!!ALSA Device nodes" >> $FILE
a26a765
        echo "!!-----------------" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
        ls -la /dev/snd/* >> $FILE
a26a765
        echo "" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
}
a26a765
a26a765
withconfigs() {
a26a765
if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]
a26a765
then
a26a765
        echo "!!ALSA configuration files" >> $FILE
a26a765
        echo "!!------------------------" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
a26a765
        #Check for ~/.asoundrc
a26a765
        if [[ -e $HOME/.asoundrc ]]
a26a765
        then
a26a765
                echo "!!User specific config file (~/.asoundrc)" >> $FILE
a26a765
                echo "" >> $FILE
a26a765
                cat $HOME/.asoundrc >> $FILE
a26a765
                echo "" >> $FILE
a26a765
                echo "" >> $FILE
a26a765
        fi
a26a765
	#Check for .asoundrc.asoundconf (seems to be Ubuntu specific)
a26a765
	if [[ -e $HOME/.asoundrc.asoundconf ]]
a26a765
	then
a26a765
		echo "!!asoundconf-generated config file" >> $FILE
a26a765
		echo "" >> $FILE
a26a765
		cat $HOME/.asoundrc.asoundconf >> $FILE
a26a765
		echo "" >> $FILE
a26a765
		echo "" >> $FILE
a26a765
	fi
a26a765
        #Check for /etc/asound.conf
a26a765
        if [[ -e /etc/asound.conf ]]
a26a765
        then
a26a765
                echo "!!System wide config file (/etc/asound.conf)" >> $FILE
a26a765
                echo "" >> $FILE
a26a765
                cat /etc/asound.conf >> $FILE
a26a765
                echo "" >> $FILE
a26a765
                echo "" >> $FILE
a26a765
        fi
a26a765
fi
a26a765
}
a26a765
a26a765
a26a765
#Run checks to make sure the programs we need are installed.
a26a765
LSPCI=$(which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
a26a765
TPUT=$(which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
a26a765
DIALOG=$(which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null);
a26a765
a26a765
#Check to see if sysfs is enabled in the kernel. We'll need this later on
a26a765
SYSFS=$(mount |grep sysfs|awk {'print $3'});
a26a765
a26a765
#Check modprobe config files for sound related options
a26a765
SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p')
a26a765
a26a765
QUESTION="yes"
a26a765
PROCEED="yes"
a26a765
NOUPLOAD=""
a26a765
REPEAT=""
a26a765
while [ -z "$REPEAT" ]; do
a26a765
REPEAT="no"
a26a765
case "$1" in
a26a765
	--update|--help|--about)
a26a765
		QUESTION="no"
a26a765
		PROCEED="no"
a26a765
		;;
a26a765
	--no-upload)
a26a765
		NOUPLOAD="yes"
a26a765
		;;
a26a765
	--no-dialog)
a26a765
		DIALOG=""
a26a765
		REPEAT=""
a26a765
		shift
a26a765
		;;
a26a765
esac
a26a765
done
a26a765
		
a26a765
a26a765
#Script header output.
a26a765
if [ "$QUESTION" = "yes" ]; then
a26a765
if [[ -n "$DIALOG" ]]
a26a765
then
a26a765
if [ -z "NOUPLOAD" ]; then
a26a765
	dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nBy default, this script will AUTOMATICALLY UPLOAD your information to a pastebin site.\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0
a26a765
else
a26a765
	dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0
a26a765
fi
a26a765
DIALOG_EXIT_CODE=$?
a26a765
if [ $DIALOG_EXIT_CODE != 0 ]; then
a26a765
echo "Thank you for using the ALSA-Info Script"
a26a765
exit 0;
a26a765
fi
a26a765
else
a26a765
a26a765
echo "ALSA Information Script v $SCRIPT_VERSION"
a26a765
echo "--------------------------------"
a26a765
echo ""
a26a765
echo "This script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem."
a26a765
echo ""
a26a765
if [ -z "$NOUPLOAD" ]; then
a26a765
if [[ -n "$TPUT" ]]; then
a26a765
tput bold
a26a765
echo "By default, the collected information will be AUTOMATICALLY uploaded to a pastebin site."
a26a765
echo "If you do not wish for this to occur, run the script with the --no-upload argument"
a26a765
tput sgr0
a26a765
else
a26a765
echo "By default, the collected information will be AUTOMATICALLY uploaded to a pastebin site."
a26a765
echo "If you do not wish for this to occur, run the script with the --no-upload argument"
a26a765
fi
a26a765
echo ""
a26a765
fi # NOUPLOAD
a26a765
echo -n "Do you want to run this script? [y/n] : "
a26a765
read -e CONFIRM
a26a765
if [ "$CONFIRM" != "y" ]; then
a26a765
echo ""
a26a765
echo "Thank you for using the ALSA-Info Script"
a26a765
exit 0;
a26a765
fi
a26a765
fi
a26a765
fi # question
a26a765
a26a765
#Set the output file
a26a765
TEMPDIR="/tmp/alsainfo/"
a26a765
FILE="/tmp/alsa-info.txt"
a26a765
a26a765
if [ "$PROCEED" = "yes" ]; then
a26a765
a26a765
if [[ -z "$LSPCI" ]] 
a26a765
	then
a26a765
	echo "This script requires lspci. Please install it, and re-run this script."
a26a765
exit 0
a26a765
fi
a26a765
a26a765
#Create the temporary work dir.
a26a765
mkdir $TEMPDIR 2>/dev/null
a26a765
a26a765
#Fetch the info and store in temp files/variables
a26a765
DISTRO=`grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS" /etc/{issue,*release,*version}`
a26a765
KERNEL_VERSION=`uname -r`
a26a765
KERNEL_PROCESSOR=`uname -p`
a26a765
KERNEL_MACHINE=`uname -m`
a26a765
KERNEL_OS=`uname -o`
a26a765
[[ `uname -v |grep SMP`  ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" 
a26a765
ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'`
a26a765
ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'`
a26a765
ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}`
a26a765
VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >/tmp/alsainfo/vendor_id.tmp`
a26a765
DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >/tmp/alsainfo/device_id.tmp`
a26a765
LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 ))
a26a765
cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>/tmp/alsainfo/alsamodules.tmp
a26a765
cat /proc/asound/cards >/tmp/alsainfo/alsacards.tmp
a26a765
lspci |grep -i "multi\|audio">/tmp/alsainfo/lspci.tmp
a26a765
a26a765
#Check for HDA-Intel cards codec#*
a26a765
cat /proc/asound/card*/codec\#* > /tmp/alsainfo/alsa-hda-intel.tmp 2> /dev/null
a26a765
a26a765
#Check for AC97 cards codec
a26a765
cat /proc/asound/card*/codec97\#0/ac97\#0-0 > /tmp/alsainfo/alsa-ac97.tmp 2> /dev/null
a26a765
cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > /tmp/alsainfo/alsa-ac97-regs.tmp 2> /dev/null
a26a765
a26a765
#Fetch the info, and put it in $FILE in a nice readable format.
a26a765
echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE
a26a765
echo "!!################################" >> $FILE
a26a765
echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE
a26a765
echo "!!################################" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!Script ran on: `LANG=C date`" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!Linux Distribution" >> $FILE
a26a765
echo "!!------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo $DISTRO >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!Kernel Information" >> $FILE
a26a765
echo "!!------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "Kernel release:    $KERNEL_VERSION" >> $FILE
a26a765
echo "Operating System:  $KERNEL_OS" >> $FILE
a26a765
echo "Architecture:      $KERNEL_MACHINE" >> $FILE
a26a765
echo "Processor:         $KERNEL_PROCESSOR" >> $FILE
a26a765
echo "SMP Enabled:       $KERNEL_SMP" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!ALSA Version" >> $FILE
a26a765
echo "!!------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "Driver version:     $ALSA_DRIVER_VERSION" >> $FILE
a26a765
echo "Library version:    $ALSA_LIB_VERSION" >> $FILE
a26a765
echo "Utilities version:  $ALSA_UTILS_VERSION" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!Loaded ALSA modules" >> $FILE
a26a765
echo "!!-------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
cat /tmp/alsainfo/alsamodules.tmp >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!Soundcards recognised by ALSA" >> $FILE
a26a765
echo "!!-----------------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
cat /tmp/alsainfo/alsacards.tmp >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!PCI Soundcards installed in the system" >> $FILE
a26a765
echo "!!--------------------------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
cat /tmp/alsainfo/lspci.tmp >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "!!Advanced information - PCI Vendor/Device/Susbsystem ID's" >> $FILE
a26a765
echo "!!--------------------------------------------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
lspci -vvn |grep -A1 040[1-3] >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
a26a765
if [ "$SNDOPTIONS" ]
a26a765
then
a26a765
echo "!!Modprobe options (Sound related)" >> $FILE
a26a765
echo "!!--------------------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' >> $FILE
a26a765
echo "" >> $FILE
a26a765
echo "" >> $FILE
a26a765
fi
a26a765
a26a765
if [ -d $SYSFS ]
a26a765
then
a26a765
echo "!!Loaded sound module options" >> $FILE
a26a765
echo "!!--------------------------" >> $FILE
a26a765
echo "" >> $FILE
a26a765
for mod in `cat /proc/asound/modules|awk {'print $2'}`;do
a26a765
echo "!!Module: $mod" >> $FILE
a26a765
for params in `ls $SYSFS/module/$mod/parameters/*`; do /bin/echo -ne "\t";/bin/echo "$params : `cat $params`"|sed 's:.*/::' >> $FILE;done
a26a765
echo "" >> $FILE
a26a765
done
a26a765
echo "" >> $FILE
a26a765
fi
a26a765
a26a765
if [ -s "/tmp/alsainfo/alsa-hda-intel.tmp" ] 
a26a765
then
a26a765
	echo "!!HDA-Intel Codec information" >> $FILE
a26a765
	echo "!!---------------------------" >> $FILE
a26a765
	echo "--startcollapse--" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	cat /tmp/alsainfo/alsa-hda-intel.tmp >> $FILE
a26a765
	echo "--endcollapse--" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
fi
a26a765
a26a765
if [ -s "/tmp/alsainfo/alsa-ac97.tmp" ]
a26a765
then
a26a765
        echo "!!AC97 Codec information" >> $FILE
a26a765
        echo "!!---------------------------" >> $FILE
a26a765
        echo "--startcollapse--" >> $FILE
a26a765
        echo "" >> $FILE
a26a765
        cat /tmp/alsainfo/alsa-ac97.tmp >> $FILE
a26a765
        echo "" >> $FILE
a26a765
        cat /tmp/alsainfo/alsa-ac97-regs.tmp >> $FILE
a26a765
        echo "--endcollapse--" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
	echo "" >> $FILE
a26a765
fi
a26a765
a26a765
a26a765
#If no command line options are specified, then run as though --with-all was specified
a26a765
if [[ -z "$1" ]]
a26a765
then
a26a765
	update
a26a765
	withdevices
a26a765
	withconfigs
a26a765
	withaplay
a26a765
	withamixer
a26a765
	withalsactl
a26a765
	withlsmod
a26a765
	#Workaround, while we sort out pastebin location, since pastebin.ca blocked us.
a26a765
	#NOUPLOAD="yes"
a26a765
	
a26a765
fi
a26a765
a26a765
fi # proceed
a26a765
a26a765
#loop through command line arguments, until none are left.
a26a765
if [[ -n "$1" ]]
a26a765
then
a26a765
	until [ -z "$1" ]
a26a765
	do
a26a765
	case "$1" in
a26a765
		--update)
a26a765
			update
a26a765
			exit
a26a765
			;;
a26a765
		--no-upload)
a26a765
			NOUPLOAD="yes"
a26a765
			KEEP_FILES="yes"
a26a765
			withdevices
a26a765
			withconfigs
a26a765
			withaplay
a26a765
			withamixer
a26a765
			withalsactl
a26a765
			withlsmod
a26a765
			;;
a26a765
		--debug)
a26a765
			echo "Debugging enabled. $FILE and $TEMPDIR will not be deleted"
a26a765
			KEEP_FILES="yes"
a26a765
			echo ""
a26a765
			withdevices
a26a765
			withconfigs
a26a765
			withaplay
a26a765
			withamixer
a26a765
			withalsactl
a26a765
			withlsmod
a26a765
			;;
a26a765
		--with-all)
a26a765
			withdevices
a26a765
			withconfigs
a26a765
			withaplay
a26a765
			withamixer
a26a765
			withalsactl
a26a765
			withlsmod
a26a765
			;;
a26a765
		#### FIX ME
a26a765
		--secure)
a26a765
			withdevices
a26a765
			withconfigs
a26a765
			withaplay
a26a765
			withamixer
a26a765
			withalsactl
a26a765
			withlsmod
a26a765
			withsecure
a26a765
			;;
a26a765
		###########
a26a765
		--with-aplay)
a26a765
			withaplay
a26a765
			;;
a26a765
		--with-amixer)
a26a765
			withamixer
a26a765
			;;
a26a765
		--with-alsactl)
a26a765
			withalsactl
a26a765
			;;
a26a765
		--with-devices)
a26a765
			withdevices
a26a765
			;;
a26a765
		--with-configs)
a26a765
			if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]]
a26a765
			then
a26a765
				echo "!!ALSA configuration files" >> $FILE
a26a765
				echo "!!------------------------" >> $FILE
a26a765
				echo "" >> $FILE
a26a765
a26a765
				#Check for ~/.asoundrc
a26a765
				if [[ -e $HOME/.asoundrc ]]
a26a765
				then
a26a765
					echo "!!User specific config file ($HOME/.asoundrc)" >> $FILE
a26a765
					echo "" >> $FILE
a26a765
					cat $HOME/.asoundrc >> $FILE
a26a765
					echo "" >> $FILE
a26a765
					echo "" >> $FILE
a26a765
				fi
a26a765
a26a765
				#Check for /etc/asound.conf
a26a765
				if [[ -e /etc/asound.conf ]]
a26a765
				then
a26a765
					echo "!!System wide config file (/etc/asound.conf)" >> $FILE
a26a765
					echo "" >> $FILE
a26a765
					cat /etc/asound.conf >> $FILE
a26a765
					echo "" >> $FILE
a26a765
					echo "" >> $FILE
a26a765
				fi
a26a765
			fi
a26a765
			;;
a26a765
		--about)
a26a765
			echo "Written/Tested by the following users of #alsa on irc.freenode.net:"
a26a765
			echo ""
a26a765
			echo "	wishie - Script author and developer / Testing"
a26a765
			echo "	crimsun - Various script ideas / Testing"
a26a765
			echo "	gnubien - Various script ideas / Testing"
a26a765
			echo "	GrueMaster - HDA Intel specific items / Testing"
a26a765
			echo "	olegfink - Script update function"
a26a765
			cleanup
a26a765
			exit 0
a26a765
			;;
a26a765
		*)
a26a765
			echo ""
a26a765
			echo "Available options:"
a26a765
			echo "	--with-aplay (includes the output of aplay -l)"
a26a765
			echo "	--with-amixer (includes the output of amixer)"
a26a765
			echo "	--with-alsactl (includes the output of alsactl)"
a26a765
			echo "	--with-configs (includes the output of ~/.asoundrc and /etc/asound.conf if they exist)" 
a26a765
			echo "	--with-devices (shows the device nodes in /dev/snd/)"
a26a765
			echo ""
a26a765
			echo "	--update (check server for script updates)"
a26a765
			echo "	--no-upload (do not upload contents to remote server)"
a26a765
			echo "	--about (show some information about the script)"
a26a765
			echo "	--debug (will run the script as normal, but will not delete $FILE)"
a26a765
			cleanup
a26a765
			exit 0
a26a765
			;;
a26a765
	esac
a26a765
	shift 1
a26a765
	done
a26a765
fi
a26a765
a26a765
if [ "$PROCEED" = "yes" ]; then
a26a765
a26a765
#Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. 
a26a765
if
a26a765
WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]]
a26a765
then
a26a765
if [[ -n "$DIALOG" ]]
a26a765
then
a26a765
	if [[ -z $NOUPLOAD ]]; then
a26a765
	wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>/tmp/alsainfo/wget.tmp || echo "Upload failed; exit"
a26a765
	{ for i in 10 20 30 40 50 60 70 80 90; do
a26a765
		echo $i
a26a765
		sleep 0.2
a26a765
	done
a26a765
	echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.pastebin.ca ..." 6 70 0
a26a765
	fi
a26a765
else
a26a765
a26a765
	if [[ -z $NOUPLOAD ]]; then
a26a765
	echo -n "Uploading information to www.pastebin.ca ... " 
a26a765
	wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>/tmp/alsainfo/wget.tmp &
a26a765
	fi
a26a765
fi
a26a765
#Progess spinner for wget transfer.
a26a765
if [[ -z "$DIALOG" ]]	
a26a765
then
a26a765
	i=1
a26a765
	sp="/-\|"
a26a765
	echo -n ' '
a26a765
	while pgrep wget &>/dev/null
a26a765
	do
a26a765
	echo -en "\b${sp:i++%${#sp}:1}"
a26a765
	done
a26a765
fi
a26a765
a26a765
#See if tput is available, and use it if it is.	
a26a765
if [[ -z $NOUPLOAD ]]; then
a26a765
	if [[ -n "$TPUT" ]]
a26a765
	then
a26a765
		FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0`
a26a765
	else
a26a765
		FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'`
a26a765
	fi
a26a765
fi
a26a765
#Output the URL of the uploaded file.	
a26a765
if [[ -z $DIALOG ]]
a26a765
then
a26a765
	echo -e "\b Done!"
a26a765
	echo ""
a26a765
	if [[ -z $NOUPLOAD ]]; then
a26a765
		echo "Your ALSA information is located at $FINAL_URL"
a26a765
		echo "Please inform the person helping you."
a26a765
		echo ""
a26a765
	fi
a26a765
fi
a26a765
if [[ -n $DIALOG ]]
a26a765
then
a26a765
	if [[ -n $NOUPLOAD ]]; then
a26a765
		dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "You requested that your information was NOT automatically uploaded to the pastebin\n\nYour ALSA information can be seen by looking in $FILE" 10 100
a26a765
	else
a26a765
		dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 
a26a765
		DIALOG_EXIT_CODE=$?
a26a765
	if [ $DIALOG_EXIT_CODE = 0 ]; then
a26a765
		grep -v "alsa-info.txt" /tmp/alsa-info.txt >/tmp/alsainfo/uploaded.txt
a26a765
		dialog --backtitle "$BGTITLE" --textbox /tmp/alsainfo/uploaded.txt 0 0
a26a765
	fi
a26a765
	fi
a26a765
fi 
a26a765
clear
a26a765
if [[ -n $NOUPLOAD ]]; then
a26a765
	echo "You requested that your information was NOT automatically uploaded to the pastebin"
a26a765
	echo ""
a26a765
	echo "Your ALSA information can be seen by looking in $FILE"
a26a765
	echo ""
a26a765
fi
a26a765
if [[ -z $NOUPLOAD ]]; then
a26a765
echo "Your ALSA information is located at $FINAL_URL"
a26a765
echo "Please inform the person helping you."
a26a765
echo ""
a26a765
fi
a26a765
	#We posted the file to pastebin.ca , so we dont need it anymore. delete it.
a26a765
	if [ -z $KEEP_FILES ]
a26a765
	then
a26a765
		rm $FILE 
a26a765
	fi
a26a765
a26a765
#We couldnt find a suitable wget, so tell the user to upload manually.
a26a765
else
a26a765
	if [[ -z $DIALOG ]]
a26a765
	then
a26a765
		echo ""
a26a765
		echo "Could not automatically upload output to http://www.pastebin.ca"
a26a765
		echo "Possible reasons are:"
a26a765
		echo "    1. Couldnt find 'wget' in your PATH"
a26a765
		echo "    2. Your version of wget is less than 1.8.2"
a26a765
		echo ""
a26a765
		echo "Please manually upload $FILE to http://www.pastebin.ca/upload.php and submit your post."
a26a765
		echo ""
a26a765
	fi
a26a765
	if [[ -n $DIALOG ]]
a26a765
	then
a26a765
		dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.pastebin.ca.\nPossible reasons are:\n\n    1. Couldn't find 'wget' in your PATH\n    2. Your version of wget is less than 1.8.2\n\nPlease manually upload $FILE to http://www.pastebin.ca/upload.php and submit your post." 25 100
a26a765
	fi
a26a765
fi
a26a765
#Clean up the temp files
a26a765
if [ -z $KEEP_FILES ]
a26a765
then
a26a765
	cleanup
a26a765
fi
a26a765
a26a765
fi # proceed