2008-04-28 10:40:55 +00:00
#!/bin/bash
2011-01-28 10:25:34 +00:00
SCRIPT_VERSION = 0.4.60
2008-07-21 10:11:54 +00:00
CHANGELOG = "http://www.alsa-project.org/alsa-info.sh.changelog"
2008-04-28 10:40:55 +00:00
#################################################################################
#Copyright (C) 2007 Free Software Foundation.
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#This program 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 General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##################################################################################
#The script was written for 2 main reasons:
# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user.
# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them.
2009-02-09 13:44:38 +00:00
#Set the locale (this may or may not be a good idea.. let me know)
export LC_ALL = C
2008-04-28 10:40:55 +00:00
#Change the PATH variable, so we can run lspci (needed for some distros)
PATH = $PATH :/bin:/sbin:/usr/bin:/usr/sbin
BGTITLE = " ALSA-Info v $SCRIPT_VERSION "
PASTEBINKEY = "C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
#Define some simple functions
2008-07-21 10:11:54 +00:00
pbcheck( ) {
2009-09-03 11:00:49 +00:00
[ [ $UPLOAD = "no" ] ] && return
2008-09-11 09:03:42 +00:00
if [ [ -z $PASTEBIN ] ] ; then
2009-09-03 11:00:49 +00:00
[ [ $( ping -c1 www.alsa-project.org) ] ] || KEEP_FILES = "yes" UPLOAD = "no" PBERROR = "yes"
2008-09-11 09:03:42 +00:00
else
2009-09-03 11:00:49 +00:00
[ [ $( ping -c1 www.pastebin.ca) ] ] || KEEP_FILES = "yes" UPLOAD = "no" PBERROR = "yes"
2008-09-11 09:03:42 +00:00
fi
2008-07-21 10:11:54 +00:00
}
2008-04-28 10:40:55 +00:00
update( ) {
2009-09-03 11:00:49 +00:00
SHFILE = ` mktemp -t alsa-info.XXXXXXXXXX` || exit 1
2009-02-09 13:44:38 +00:00
wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>& 1
REMOTE_VERSION = ` grep SCRIPT_VERSION $SHFILE | head -n1 | sed 's/.*=//' `
2008-04-28 10:40:55 +00:00
if [ " $REMOTE_VERSION " != " $SCRIPT_VERSION " ] ; then
if [ [ -n $DIALOG ] ]
then
2009-02-09 13:44:38 +00:00
OVERWRITE =
2008-11-04 09:46:31 +00:00
if [ -w $0 ] ; then
2009-02-09 13:44:38 +00:00
dialog --yesno " Newer version of ALSA-Info has been found\n\nDo you wish to install it?\nNOTICE: The original file $0 will be overwritten! " 0 0
DIALOG_EXIT_CODE = $?
if [ [ $DIALOG_EXIT_CODE = 0 ] ] ; then
OVERWRITE = yes
fi
fi
if [ -z " $OVERWRITE " ] ; then
2008-11-04 09:46:31 +00:00
dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to download it?" 0 0
2009-02-09 13:44:38 +00:00
DIALOG_EXIT_CODE = $?
2008-11-04 09:46:31 +00:00
fi
2008-04-28 10:40:55 +00:00
if [ [ $DIALOG_EXIT_CODE = 0 ] ]
then
2008-11-04 09:46:31 +00:00
echo " Newer version detected: $REMOTE_VERSION "
2008-04-28 10:40:55 +00:00
echo " To view the ChangeLog, please visit $CHANGELOG "
2009-02-09 13:44:38 +00:00
if [ " $OVERWRITE " = "yes" ] ; then
cp $SHFILE $0
2008-11-04 09:46:31 +00:00
echo " ALSA-Info script has been updated to v $REMOTE_VERSION "
echo "Please re-run the script"
2009-02-09 13:44:38 +00:00
rm $SHFILE 2>/dev/null
2008-11-04 09:46:31 +00:00
else
2009-09-03 11:00:49 +00:00
echo " ALSA-Info script has been downloaded as $SHFILE . "
2008-11-04 09:46:31 +00:00
echo "Please re-run the script from new location."
fi
2008-04-28 10:40:55 +00:00
exit
2008-11-04 09:46:31 +00:00
else
2009-02-09 13:44:38 +00:00
rm $SHFILE 2>/dev/null
2008-04-28 10:40:55 +00:00
fi
else
echo " Newer version detected: $REMOTE_VERSION "
echo " To view the ChangeLog, please visit $CHANGELOG "
2008-11-04 09:46:31 +00:00
if [ -w $0 ] ; then
2009-02-09 13:44:38 +00:00
echo " The original file $0 will be overwritten! "
echo -n "If you do not like to proceed, press Ctrl-C now.." ; read inp
cp $SHFILE $0
2008-11-04 09:46:31 +00:00
echo "ALSA-Info script has been updated. Please re-run it."
2009-02-09 13:44:38 +00:00
rm $SHFILE 2>/dev/null
2008-11-04 09:46:31 +00:00
else
2009-09-03 11:00:49 +00:00
echo " ALSA-Info script has been downloaded $SHFILE . "
2008-11-04 09:46:31 +00:00
echo "Please, re-run it from new location."
fi
2008-04-28 10:40:55 +00:00
exit
fi
2008-11-04 09:46:31 +00:00
else
2009-02-09 13:44:38 +00:00
rm $SHFILE 2>/dev/null
2008-04-28 10:40:55 +00:00
fi
}
cleanup( ) {
2009-05-06 09:24:34 +00:00
if [ -n " $TEMPDIR " -a " $KEEP_FILES " != "yes" ] ; then
2009-09-03 11:00:49 +00:00
rm -rf " $TEMPDIR " 2>/dev/null
2009-05-06 09:24:34 +00:00
fi
2009-09-03 11:00:49 +00:00
test -n " $KEEP_OUTPUT " || rm -f " $NFILE "
2008-04-28 10:40:55 +00:00
}
withaplay( ) {
echo "!!Aplay/Arecord output" >> $FILE
echo "!!------------" >> $FILE
echo "" >> $FILE
echo "APLAY" >> $FILE
echo "" >> $FILE
2008-07-21 10:11:54 +00:00
aplay -l >> $FILE 2>& 1
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
echo "ARECORD" >> $FILE
echo "" >> $FILE
2008-07-21 10:11:54 +00:00
arecord -l >> $FILE 2>& 1
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
}
withlsmod( ) {
echo "!!All Loaded Modules" >> $FILE
echo "!!------------------" >> $FILE
echo "" >> $FILE
lsmod | awk { 'print $1' } >> $FILE
echo "" >> $FILE
echo "" >> $FILE
}
withamixer( ) {
echo "!!Amixer output" >> $FILE
echo "!!-------------" >> $FILE
echo "" >> $FILE
for i in ` grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} ' ` ; do
2009-02-09 13:44:38 +00:00
CARD_NAME = ` grep " ^ * $i " $TEMPDIR /alsacards.tmp| awk { 'print $2' } `
2008-04-28 10:40:55 +00:00
echo " !!-------Mixer controls for card $i $CARD_NAME ] " >> $FILE
echo "" >>$FILE
2008-09-11 09:03:42 +00:00
amixer -c$i info>> $FILE 2>& 1
2008-07-21 10:11:54 +00:00
amixer -c$i >> $FILE 2>& 1
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
done
echo "" >> $FILE
}
withalsactl( ) {
echo "!!Alsactl output" >> $FILE
echo "!!-------------" >> $FILE
echo "" >> $FILE
exe = ""
if [ -x /usr/sbin/alsactl ] ; then
exe = "/usr/sbin/alsactl"
fi
if [ -x /usr/local/sbin/alsactl ] ; then
exe = "/usr/local/sbin/alsactl"
fi
if [ -z " $exe " ] ; then
exe = ` whereis alsactl | cut -d ' ' -f 2`
fi
2009-02-09 13:44:38 +00:00
$exe -f $TEMPDIR /alsactl.tmp store
2008-04-28 10:40:55 +00:00
echo "--startcollapse--" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /alsactl.tmp >> $FILE
2008-04-28 10:40:55 +00:00
echo "--endcollapse--" >> $FILE
echo "" >> $FILE
echo "" >> $FILE
}
withdevices( ) {
echo "!!ALSA Device nodes" >> $FILE
echo "!!-----------------" >> $FILE
echo "" >> $FILE
ls -la /dev/snd/* >> $FILE
echo "" >> $FILE
echo "" >> $FILE
}
withconfigs( ) {
if [ [ -e $HOME /.asoundrc ] ] || [ [ -e /etc/asound.conf ] ] || [ [ -e $HOME /.asoundrc.asoundconf ] ]
then
echo "!!ALSA configuration files" >> $FILE
echo "!!------------------------" >> $FILE
echo "" >> $FILE
#Check for ~/.asoundrc
if [ [ -e $HOME /.asoundrc ] ]
then
echo "!!User specific config file (~/.asoundrc)" >> $FILE
echo "" >> $FILE
cat $HOME /.asoundrc >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
#Check for .asoundrc.asoundconf (seems to be Ubuntu specific)
if [ [ -e $HOME /.asoundrc.asoundconf ] ]
then
echo "!!asoundconf-generated config file" >> $FILE
echo "" >> $FILE
cat $HOME /.asoundrc.asoundconf >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
#Check for /etc/asound.conf
if [ [ -e /etc/asound.conf ] ]
then
echo "!!System wide config file (/etc/asound.conf)" >> $FILE
echo "" >> $FILE
cat /etc/asound.conf >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
fi
}
2009-05-06 09:24:34 +00:00
withsysfs( ) {
local i f
local printed = ""
for i in /sys/class/sound/*; do
case " $i " in
*/hwC?D?)
if [ -f $i /init_pin_configs ] ; then
if [ -z " $printed " ] ; then
echo "!!Sysfs Files" >> $FILE
echo "!!-----------" >> $FILE
echo "" >> $FILE
fi
for f in init_pin_configs driver_pin_configs user_pin_configs init_verbs; do
echo " $i / $f : " >> $FILE
cat $i /$f >> $FILE
echo >> $FILE
done
printed = yes
fi
; ;
esac
done
if [ -n " $printed " ] ; then
echo "" >> $FILE
fi
}
2009-09-03 11:00:49 +00:00
withdmesg( ) {
echo "!!ALSA/HDA dmesg" >> $FILE
echo "!!------------------" >> $FILE
echo "" >> $FILE
dmesg | grep -C1 -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' >> $FILE
echo "" >> $FILE
echo "" >> $FILE
}
withall( ) {
withdevices
withconfigs
withaplay
withamixer
withalsactl
withlsmod
withsysfs
withdmesg
}
2009-05-06 09:24:34 +00:00
get_alsa_library_version( ) {
ALSA_LIB_VERSION = ` grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null| awk { 'print $3' } | sed 's/"//g' `
if [ -z " $ALSA_LIB_VERSION " ] ; then
if [ -f /etc/lsb-release ] ; then
. /etc/lsb-release
case " $DISTRIB_ID " in
Ubuntu)
if which dpkg > /dev/null ; then
ALSA_LIB_VERSION = ` dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
fi
if [ " $ALSA_LIB_VERSION " = "<none>" ] ; then
ALSA_LIB_VERSION = ""
fi
return
; ;
*)
return
; ;
esac
elif [ -f /etc/debian_version ] ; then
if which dpkg > /dev/null ; then
ALSA_LIB_VERSION = ` dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
fi
if [ " $ALSA_LIB_VERSION " = "<none>" ] ; then
ALSA_LIB_VERSION = ""
fi
return
fi
fi
}
2008-04-28 10:40:55 +00:00
#Run checks to make sure the programs we need are installed.
LSPCI = $( which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) ;
TPUT = $( which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) ;
DIALOG = $( which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null) ;
#Check to see if sysfs is enabled in the kernel. We'll need this later on
SYSFS = $( mount | grep sysfs| awk { 'print $3' } ) ;
#Check modprobe config files for sound related options
SNDOPTIONS = $( modprobe -c| sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' )
2009-09-03 11:00:49 +00:00
KEEP_OUTPUT =
NFILE = ""
2008-09-11 09:03:42 +00:00
PASTEBIN = ""
WWWSERVICE = "www.alsa-project.org"
2009-09-03 11:00:49 +00:00
WELCOME = "yes"
2008-04-28 10:40:55 +00:00
PROCEED = "yes"
2009-09-03 11:00:49 +00:00
UPLOAD = "ask"
2008-04-28 10:40:55 +00:00
REPEAT = ""
while [ -z " $REPEAT " ] ; do
REPEAT = "no"
case " $1 " in
--update| --help| --about)
2009-09-03 11:00:49 +00:00
WELCOME = "no"
2008-04-28 10:40:55 +00:00
PROCEED = "no"
; ;
2009-09-03 11:00:49 +00:00
--upload)
UPLOAD = "yes"
WELCOME = "no"
; ;
2008-04-28 10:40:55 +00:00
--no-upload)
2009-09-03 11:00:49 +00:00
UPLOAD = "no"
WELCOME = "no"
2008-04-28 10:40:55 +00:00
; ;
2008-09-11 09:03:42 +00:00
--pastebin)
PASTEBIN = "yes"
WWWSERVICE = "pastebin"
; ;
2008-04-28 10:40:55 +00:00
--no-dialog)
DIALOG = ""
REPEAT = ""
shift
; ;
2009-05-06 09:24:34 +00:00
--stdout)
DIALOG = ""
2009-09-03 11:00:49 +00:00
UPLOAD = "no"
WELCOME = "no"
2009-05-06 09:24:34 +00:00
TOSTDOUT = "yes"
; ;
2008-04-28 10:40:55 +00:00
esac
done
2009-09-03 11:00:49 +00:00
#Script header output.
if [ " $WELCOME " = "yes" ] ; then
greeting_message = " \
This script visits the following commands/files to collect diagnostic
information about your ALSA installation and sound related hardware.
dmesg
lspci
lsmod
aplay
amixer
alsactl
/proc/asound/
/sys/class/sound/
~/.asoundrc ( etc.)
See '$0 --help' for command line options.
"
if [ [ -n " $DIALOG " ] ] ; then
dialog --backtitle " $BGTITLE " \
--title " ALSA-Info script v $SCRIPT_VERSION " \
--msgbox " $greeting_message " 20 80
2008-04-28 10:40:55 +00:00
else
2009-09-03 11:00:49 +00:00
echo " ALSA Information Script v $SCRIPT_VERSION "
echo "--------------------------------"
echo " $greeting_message "
fi # dialog
fi # WELCOME
2008-04-28 10:40:55 +00:00
#Set the output file
2009-09-03 11:00:49 +00:00
TEMPDIR = ` mktemp -t -d alsa-info.XXXXXXXXXX` || exit 1
2009-02-09 13:44:38 +00:00
FILE = " $TEMPDIR /alsa-info.txt "
2009-09-03 11:00:49 +00:00
if [ -z " $NFILE " ] ; then
NFILE = ` mktemp -t alsa-info.txt.XXXXXXXXXX` || exit 1
fi
2008-04-28 10:40:55 +00:00
2009-05-06 09:24:34 +00:00
trap cleanup 0
2008-04-28 10:40:55 +00:00
if [ " $PROCEED " = "yes" ] ; then
if [ [ -z " $LSPCI " ] ]
2009-05-06 09:24:34 +00:00
then
2008-04-28 10:40:55 +00:00
echo "This script requires lspci. Please install it, and re-run this script."
2009-05-06 09:24:34 +00:00
exit 0
2008-04-28 10:40:55 +00:00
fi
#Fetch the info and store in temp files/variables
2008-07-21 10:11:54 +00:00
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\|Pardus" /etc/{ issue,*release,*version} `
2008-04-28 10:40:55 +00:00
KERNEL_VERSION = ` uname -r`
KERNEL_PROCESSOR = ` uname -p`
KERNEL_MACHINE = ` uname -m`
KERNEL_OS = ` uname -o`
[ [ ` uname -v | grep SMP` ] ] && KERNEL_SMP = "Yes" || KERNEL_SMP = "No"
ALSA_DRIVER_VERSION = ` cat /proc/asound/version | head -n1| awk { 'print $7' } | sed 's/\.$//' `
2009-05-06 09:24:34 +00:00
get_alsa_library_version
2008-04-28 10:40:55 +00:00
ALSA_UTILS_VERSION = ` amixer -v | awk { 'print $3' } `
2009-02-09 13:44:38 +00:00
VENDOR_ID = ` lspci -vn | grep 040[ 1-3] | awk -F':' '{print $3}' | awk { 'print substr($0, 2);}' >$TEMPDIR /vendor_id.tmp`
DEVICE_ID = ` lspci -vn | grep 040[ 1-3] | awk -F':' '{print $4}' | awk { 'print $1' } >$TEMPDIR /device_id.tmp`
2008-04-28 10:40:55 +00:00
LAST_CARD = $(( ` grep "]: " /proc/asound/cards | wc -l` - 1 ))
2009-02-09 13:44:38 +00:00
ESDINST = $( which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
PAINST = $( which pulseaudio 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
ARTSINST = $( which artsd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
2009-05-06 09:24:34 +00:00
JACKINST = $( which jackd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
2009-09-03 11:00:49 +00:00
DMIDECODE = $( which dmidecode 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
#Check for DMI data
if [ -d /sys/class/dmi/id ] ; then
# No root privileges are required when using sysfs method
DMI_SYSTEM_MANUFACTURER = $( cat /sys/class/dmi/id/sys_vendor 2>/dev/null)
DMI_SYSTEM_PRODUCT_NAME = $( cat /sys/class/dmi/id/product_name 2>/dev/null)
2011-01-28 10:25:34 +00:00
DMI_SYSTEM_PRODUCT_VERSION = $( cat /sys/class/dmi/id/product_version 2>/dev/null)
2009-09-03 11:00:49 +00:00
elif [ -x $DMIDECODE ] ; then
DMI_SYSTEM_MANUFACTURER = $( $DMIDECODE -s system-manufacturer 2>/dev/null)
DMI_SYSTEM_PRODUCT_NAME = $( $DMIDECODE -s system-product-name 2>/dev/null)
2011-01-28 10:25:34 +00:00
DMI_SYSTEM_PRODUCT_VERSION = $( $DMIDECODE -s system-version 2>/dev/null)
2009-09-03 11:00:49 +00:00
fi
2009-02-09 13:44:38 +00:00
cat /proc/asound/modules 2>/dev/null| awk { 'print $2' } >$TEMPDIR /alsamodules.tmp
cat /proc/asound/cards >$TEMPDIR /alsacards.tmp
lspci | grep -i "multi\|audio" >$TEMPDIR /lspci.tmp
2008-04-28 10:40:55 +00:00
#Check for HDA-Intel cards codec#*
2009-02-09 13:44:38 +00:00
cat /proc/asound/card*/codec\# * > $TEMPDIR /alsa-hda-intel.tmp 2> /dev/null
2008-04-28 10:40:55 +00:00
#Check for AC97 cards codec
2009-02-09 13:44:38 +00:00
cat /proc/asound/card*/codec97\# 0/ac97\# 0-0 > $TEMPDIR /alsa-ac97.tmp 2> /dev/null
cat /proc/asound/card*/codec97\# 0/ac97\# 0-0+regs > $TEMPDIR /alsa-ac97-regs.tmp 2> /dev/null
2008-04-28 10:40:55 +00:00
2010-06-28 12:15:32 +00:00
#Check for USB mixer setup
cat /proc/asound/card*/usbmixer > $TEMPDIR /alsa-usbmixer.tmp 2> /dev/null
2008-04-28 10:40:55 +00:00
#Fetch the info, and put it in $FILE in a nice readable format.
2008-09-11 09:03:42 +00:00
if [ [ -z $PASTEBIN ] ] ; then
echo "upload=true&script=true&cardinfo=" > $FILE
else
2008-04-28 10:40:55 +00:00
echo " name= $USER &type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content= " > $FILE
2008-09-11 09:03:42 +00:00
fi
2008-04-28 10:40:55 +00:00
echo "!!################################" >> $FILE
echo " !!ALSA Information Script v $SCRIPT_VERSION " >> $FILE
echo "!!################################" >> $FILE
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
echo "!!Script ran on: `LANG=C TZ=UTC date`" >> $FILE
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
echo "" >> $FILE
echo "!!Linux Distribution" >> $FILE
echo "!!------------------" >> $FILE
echo "" >> $FILE
echo $DISTRO >> $FILE
echo "" >> $FILE
echo "" >> $FILE
2009-09-03 11:00:49 +00:00
echo "!!DMI Information" >> $FILE
echo "!!---------------" >> $FILE
echo "" >> $FILE
echo " Manufacturer: $DMI_SYSTEM_MANUFACTURER " >> $FILE
echo " Product Name: $DMI_SYSTEM_PRODUCT_NAME " >> $FILE
2011-01-28 10:25:34 +00:00
echo " Product Version: $DMI_SYSTEM_PRODUCT_VERSION " >> $FILE
2009-09-03 11:00:49 +00:00
echo "" >> $FILE
echo "" >> $FILE
2008-04-28 10:40:55 +00:00
echo "!!Kernel Information" >> $FILE
echo "!!------------------" >> $FILE
echo "" >> $FILE
echo " Kernel release: $KERNEL_VERSION " >> $FILE
echo " Operating System: $KERNEL_OS " >> $FILE
echo " Architecture: $KERNEL_MACHINE " >> $FILE
echo " Processor: $KERNEL_PROCESSOR " >> $FILE
echo " SMP Enabled: $KERNEL_SMP " >> $FILE
echo "" >> $FILE
echo "" >> $FILE
echo "!!ALSA Version" >> $FILE
echo "!!------------" >> $FILE
echo "" >> $FILE
echo " Driver version: $ALSA_DRIVER_VERSION " >> $FILE
echo " Library version: $ALSA_LIB_VERSION " >> $FILE
echo " Utilities version: $ALSA_UTILS_VERSION " >> $FILE
echo "" >> $FILE
echo "" >> $FILE
echo "!!Loaded ALSA modules" >> $FILE
echo "!!-------------------" >> $FILE
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /alsamodules.tmp >> $FILE
echo "" >> $FILE
echo "" >> $FILE
echo "!!Sound Servers on this system" >> $FILE
echo "!!----------------------------" >> $FILE
echo "" >> $FILE
if [ [ -n $PAINST ] ] ; then
2009-05-06 09:24:34 +00:00
[ [ ` pgrep '^(.*/)?pulseaudio$' ` ] ] && PARUNNING = "Yes" || PARUNNING = "No"
2009-02-09 13:44:38 +00:00
echo "Pulseaudio:" >> $FILE
echo " Installed - Yes ( $PAINST ) " >> $FILE
echo " Running - $PARUNNING " >> $FILE
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
fi
if [ [ -n $ESDINST ] ] ; then
2009-05-06 09:24:34 +00:00
[ [ ` pgrep '^(.*/)?esd$' ` ] ] && ESDRUNNING = "Yes" || ESDRUNNING = "No"
2009-02-09 13:44:38 +00:00
echo "ESound Daemon:" >> $FILE
echo " Installed - Yes ( $ESDINST ) " >> $FILE
echo " Running - $ESDRUNNING " >> $FILE
echo "" >> $FILE
fi
if [ [ -n $ARTSINST ] ] ; then
2009-05-06 09:24:34 +00:00
[ [ ` pgrep '^(.*/)?artsd$' ` ] ] && ARTSRUNNING = "Yes" || ARTSRUNNING = "No"
2009-02-09 13:44:38 +00:00
echo "aRts:" >> $FILE
echo " Installed - Yes ( $ARTSINST ) " >> $FILE
echo " Running - $ARTSRUNNING " >> $FILE
echo "" >> $FILE
fi
2009-05-06 09:24:34 +00:00
if [ [ -n $JACKINST ] ] ; then
[ [ ` pgrep '^(.*/)?jackd$' ` ] ] && JACKRUNNING = "Yes" || JACKRUNNING = "No"
echo "Jack:" >> $FILE
echo " Installed - Yes ( $JACKINST ) " >> $FILE
echo " Running - $JACKRUNNING " >> $FILE
echo "" >> $FILE
fi
if [ [ -z " $PAINST " && -z " $ESDINST " && -z " $ARTSINST " && -z " $JACKINST " ] ] ; then
2009-02-09 13:44:38 +00:00
echo "No sound servers found." >> $FILE
echo "" >> $FILE
fi
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
echo "!!Soundcards recognised by ALSA" >> $FILE
echo "!!-----------------------------" >> $FILE
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /alsacards.tmp >> $FILE
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
echo "" >> $FILE
echo "!!PCI Soundcards installed in the system" >> $FILE
echo "!!--------------------------------------" >> $FILE
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /lspci.tmp >> $FILE
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
echo "" >> $FILE
2011-01-28 10:25:34 +00:00
echo "!!Advanced information - PCI Vendor/Device/Subsystem ID's" >> $FILE
2008-04-28 10:40:55 +00:00
echo "!!--------------------------------------------------------" >> $FILE
echo "" >> $FILE
lspci -vvn | grep -A1 040[ 1-3] >> $FILE
echo "" >> $FILE
echo "" >> $FILE
if [ " $SNDOPTIONS " ]
then
echo "!!Modprobe options (Sound related)" >> $FILE
echo "!!--------------------------------" >> $FILE
echo "" >> $FILE
modprobe -c| sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
2008-11-04 09:46:31 +00:00
if [ -d " $SYSFS " ]
2008-04-28 10:40:55 +00:00
then
echo "!!Loaded sound module options" >> $FILE
echo "!!--------------------------" >> $FILE
echo "" >> $FILE
for mod in ` cat /proc/asound/modules| awk { 'print $2' } ` ; do
echo " !!Module: $mod " >> $FILE
2009-09-03 11:00:49 +00:00
for params in ` echo $SYSFS /module/$mod /parameters/*` ; do
echo -ne "\t" ;
echo " $params : `cat $params ` " | sed 's:.*/::' ;
done >> $FILE
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
done
echo "" >> $FILE
fi
2009-02-09 13:44:38 +00:00
if [ -s " $TEMPDIR /alsa-hda-intel.tmp " ]
2008-04-28 10:40:55 +00:00
then
echo "!!HDA-Intel Codec information" >> $FILE
echo "!!---------------------------" >> $FILE
echo "--startcollapse--" >> $FILE
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /alsa-hda-intel.tmp >> $FILE
2008-04-28 10:40:55 +00:00
echo "--endcollapse--" >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
2009-02-09 13:44:38 +00:00
if [ -s " $TEMPDIR /alsa-ac97.tmp " ]
2008-04-28 10:40:55 +00:00
then
echo "!!AC97 Codec information" >> $FILE
echo "!!---------------------------" >> $FILE
echo "--startcollapse--" >> $FILE
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /alsa-ac97.tmp >> $FILE
2008-04-28 10:40:55 +00:00
echo "" >> $FILE
2009-02-09 13:44:38 +00:00
cat $TEMPDIR /alsa-ac97-regs.tmp >> $FILE
2008-04-28 10:40:55 +00:00
echo "--endcollapse--" >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
2010-06-28 12:15:32 +00:00
if [ -s " $TEMPDIR /alsa-usbmixer.tmp " ]
then
echo "!!USB Mixer information" >> $FILE
echo "!!---------------------------" >> $FILE
echo "--startcollapse--" >> $FILE
echo "" >> $FILE
cat $TEMPDIR /alsa-usbmixer.tmp >> $FILE
echo "--endcollapse--" >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
2008-04-28 10:40:55 +00:00
#If no command line options are specified, then run as though --with-all was specified
if [ [ -z " $1 " ] ]
then
update
2009-09-03 11:00:49 +00:00
withall
2008-07-21 10:11:54 +00:00
pbcheck
2008-04-28 10:40:55 +00:00
fi
fi # proceed
#loop through command line arguments, until none are left.
if [ [ -n " $1 " ] ]
then
until [ -z " $1 " ]
do
case " $1 " in
2008-09-11 09:03:42 +00:00
--pastebin)
update
2009-09-03 11:00:49 +00:00
withall
2008-09-11 09:03:42 +00:00
pbcheck
; ;
2008-04-28 10:40:55 +00:00
--update)
update
exit
; ;
2009-09-03 11:00:49 +00:00
--upload)
UPLOAD = "yes"
withall
; ;
2008-04-28 10:40:55 +00:00
--no-upload)
2009-09-03 11:00:49 +00:00
UPLOAD = "no"
withall
; ;
--output)
shift
NFILE = " $1 "
KEEP_OUTPUT = "yes"
2008-04-28 10:40:55 +00:00
; ;
--debug)
echo " Debugging enabled. $FILE and $TEMPDIR will not be deleted "
KEEP_FILES = "yes"
echo ""
2009-09-03 11:00:49 +00:00
withall
2008-04-28 10:40:55 +00:00
; ;
--with-all)
2009-09-03 11:00:49 +00:00
withall
2008-04-28 10:40:55 +00:00
; ;
--with-aplay)
withaplay
; ;
--with-amixer)
withamixer
; ;
--with-alsactl)
withalsactl
; ;
--with-devices)
withdevices
; ;
2009-09-03 11:00:49 +00:00
--with-dmesg)
withdmesg
; ;
2008-04-28 10:40:55 +00:00
--with-configs)
if [ [ -e $HOME /.asoundrc ] ] || [ [ -e /etc/asound.conf ] ]
then
echo "!!ALSA configuration files" >> $FILE
echo "!!------------------------" >> $FILE
echo "" >> $FILE
#Check for ~/.asoundrc
if [ [ -e $HOME /.asoundrc ] ]
then
echo " !!User specific config file ( $HOME /.asoundrc) " >> $FILE
echo "" >> $FILE
cat $HOME /.asoundrc >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
#Check for /etc/asound.conf
if [ [ -e /etc/asound.conf ] ]
then
echo "!!System wide config file (/etc/asound.conf)" >> $FILE
echo "" >> $FILE
cat /etc/asound.conf >> $FILE
echo "" >> $FILE
echo "" >> $FILE
fi
fi
; ;
2009-05-06 09:24:34 +00:00
--stdout)
2009-09-03 11:00:49 +00:00
UPLOAD = "no"
withall
2009-05-06 09:24:34 +00:00
cat $FILE
rm $FILE
; ;
2008-04-28 10:40:55 +00:00
--about)
echo "Written/Tested by the following users of #alsa on irc.freenode.net:"
echo ""
echo " wishie - Script author and developer / Testing"
echo " crimsun - Various script ideas / Testing"
echo " gnubien - Various script ideas / Testing"
echo " GrueMaster - HDA Intel specific items / Testing"
echo " olegfink - Script update function"
2009-05-06 09:24:34 +00:00
echo " TheMuso - display to stdout functionality"
2008-04-28 10:40:55 +00:00
exit 0
; ;
*)
2008-09-11 09:03:42 +00:00
echo " alsa-info.sh version $SCRIPT_VERSION "
2008-04-28 10:40:55 +00:00
echo ""
echo "Available options:"
echo " --with-aplay (includes the output of aplay -l)"
echo " --with-amixer (includes the output of amixer)"
echo " --with-alsactl (includes the output of alsactl)"
2008-09-11 09:03:42 +00:00
echo " --with-configs (includes the output of ~/.asoundrc and"
echo " /etc/asound.conf if they exist)"
2008-04-28 10:40:55 +00:00
echo " --with-devices (shows the device nodes in /dev/snd/)"
2009-09-03 11:00:49 +00:00
echo " --with-dmesg (shows the ALSA/HDA kernel messages)"
2008-04-28 10:40:55 +00:00
echo ""
2009-09-03 11:00:49 +00:00
echo " --output FILE (specify the file to output for no-upload mode)"
2008-04-28 10:40:55 +00:00
echo " --update (check server for script updates)"
2009-09-03 11:00:49 +00:00
echo " --upload (upload contents to remote server)"
2008-04-28 10:40:55 +00:00
echo " --no-upload (do not upload contents to remote server)"
2008-09-11 09:03:42 +00:00
echo " --pastebin (use http://pastebin.ca) as remote server"
echo " instead www.alsa-project.org"
2009-09-03 11:00:49 +00:00
echo " --stdout (print alsa information to standard output"
echo " instead of a file)"
2008-04-28 10:40:55 +00:00
echo " --about (show some information about the script)"
2008-09-11 09:03:42 +00:00
echo " --debug (will run the script as normal, but will not"
echo " delete $FILE ) "
2008-04-28 10:40:55 +00:00
exit 0
; ;
esac
shift 1
done
fi
2009-05-06 09:24:34 +00:00
if [ " $PROCEED " = "no" ] ; then
exit 1
fi
2009-09-03 11:00:49 +00:00
if [ " $UPLOAD " = "ask" ] ; then
if [ [ -n " $DIALOG " ] ] ; then
dialog --backtitle " $BGTITLE " --title "Information collected" --yes-label " UPLOAD / SHARE " --no-label " SAVE LOCALLY " --defaultno --yesno " \n\nAutomatically upload ALSA information to $WWWSERVICE ? " 10 80
DIALOG_EXIT_CODE = $?
if [ $DIALOG_EXIT_CODE != 0 ] ; then
UPLOAD = "no"
else
UPLOAD = "yes"
fi
else
echo -n " Automatically upload ALSA information to $WWWSERVICE ? [y/N] : "
read -e CONFIRM
if [ " $CONFIRM " != "y" ] ; then
UPLOAD = "no"
else
UPLOAD = "yes"
fi
fi
fi
if [ " $UPLOAD " = "no" ] ; then
2009-05-06 09:24:34 +00:00
if [ -z " $TOSTDOUT " ] ; then
2009-09-03 11:00:49 +00:00
mv -f $FILE $NFILE || exit 1
KEEP_OUTPUT = "yes"
2009-05-06 09:24:34 +00:00
fi
if [ [ -n $DIALOG ] ]
then
if [ [ -n $PBERROR ] ] ; then
2009-09-03 11:00:49 +00:00
dialog --backtitle " $BGTITLE " --title "Information collected" --msgbox " An error occurred while contacting the $WWWSERVICE .\n Your information was NOT automatically uploaded.\n\nYour ALSA information is in $NFILE " 10 100
2009-05-06 09:24:34 +00:00
else
2009-09-03 11:00:49 +00:00
dialog --backtitle " $BGTITLE " --title "Information collected" --msgbox " \n\nYour ALSA information is in $NFILE " 10 60
2009-05-06 09:24:34 +00:00
fi
else
echo
if [ [ -n $PBERROR ] ] ; then
2009-09-03 11:00:49 +00:00
echo " An error occurred while contacting the $WWWSERVICE . "
echo "Your information was NOT automatically uploaded."
2009-05-06 09:24:34 +00:00
echo ""
2009-09-03 11:00:49 +00:00
echo " Your ALSA information is in $NFILE "
2009-05-06 09:24:34 +00:00
echo ""
else
if [ -z " $TOSTDOUT " ] ; then
echo ""
2009-09-03 11:00:49 +00:00
echo " Your ALSA information is in $NFILE "
2009-05-06 09:24:34 +00:00
echo ""
fi
fi
fi
exit
2009-09-03 11:00:49 +00:00
fi # UPLOAD
2008-04-28 10:40:55 +00:00
#Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt.
if
WGET = $( which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) ; [ [ -n " ${ WGET } " ] ] && [ [ -x " ${ WGET } " ] ] && [ [ ` wget --help | grep post-file` ] ]
then
2009-05-06 09:24:34 +00:00
if [ [ -n $DIALOG ] ]
2008-04-28 10:40:55 +00:00
then
2009-05-06 09:24:34 +00:00
if [ [ -z $PASTEBIN ] ] ; then
2009-02-09 13:44:38 +00:00
wget -O - --tries= 5 --timeout= 60 --post-file= $FILE "http://www.alsa-project.org/cardinfo-db/" & >$TEMPDIR /wget.tmp || echo "Upload failed; exit"
2008-09-11 09:03:42 +00:00
{ for i in 10 20 30 40 50 60 70 80 90; do
echo $i
sleep 0.2
done
echo; } | dialog --backtitle " $BGTITLE " --guage "Uploading information to www.alsa-project.org ..." 6 70 0
2009-05-06 09:24:34 +00:00
else
2009-02-09 13:44:38 +00:00
wget -O - --tries= 5 --timeout= 60 --post-file= $FILE " http://pastebin.ca/quiet-paste.php?api= $PASTEBINKEY &encrypt=t&encryptpw=blahblah " & >$TEMPDIR /wget.tmp || echo "Upload failed; exit"
2008-04-28 10:40:55 +00:00
{ for i in 10 20 30 40 50 60 70 80 90; do
echo $i
sleep 0.2
done
echo; } | dialog --backtitle " $BGTITLE " --guage "Uploading information to www.pastebin.ca ..." 6 70 0
2009-05-06 09:24:34 +00:00
fi
dialog --backtitle " $BGTITLE " --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100
DIALOG_EXIT_CODE = $?
if [ $DIALOG_EXIT_CODE = 0 ] ; then
grep -v "alsa-info.txt" $FILE >$TEMPDIR /uploaded.txt
dialog --backtitle " $BGTITLE " --textbox $TEMPDIR /uploaded.txt 0 0
fi
clear
# no dialog
2008-04-28 10:40:55 +00:00
else
2009-05-06 09:24:34 +00:00
if [ [ -z $PASTEBIN ] ] ; then
2008-09-11 09:03:42 +00:00
echo -n "Uploading information to www.alsa-project.org ... "
2009-02-09 13:44:38 +00:00
wget -O - --tries= 5 --timeout= 60 --post-file= $FILE http://www.alsa-project.org/cardinfo-db/ & >$TEMPDIR /wget.tmp &
2009-05-06 09:24:34 +00:00
else
2008-04-28 10:40:55 +00:00
echo -n "Uploading information to www.pastebin.ca ... "
2009-02-09 13:44:38 +00:00
wget -O - --tries= 5 --timeout= 60 --post-file= $FILE http://pastebin.ca/quiet-paste.php?api= $PASTEBINKEY & >$TEMPDIR /wget.tmp &
2008-04-28 10:40:55 +00:00
fi
2009-05-06 09:24:34 +00:00
2008-04-28 10:40:55 +00:00
#Progess spinner for wget transfer.
2009-05-06 09:24:34 +00:00
i = 1
sp = "/-\|"
echo -n ' '
while pgrep wget & >/dev/null
do
2008-04-28 10:40:55 +00:00
echo -en " \b ${ sp : i ++% ${# sp } : 1 } "
2009-05-06 09:24:34 +00:00
done
echo -e "\b Done!"
echo ""
fi #dialog
2008-04-28 10:40:55 +00:00
#See if tput is available, and use it if it is.
2009-05-06 09:24:34 +00:00
if [ [ -n " $TPUT " ] ]
2008-04-28 10:40:55 +00:00
then
2009-05-06 09:24:34 +00:00
if [ [ -z $PASTEBIN ] ] ; then
FINAL_URL = ` tput setaf 1; grep "SUCCESS:" $TEMPDIR /wget.tmp | cut -d ' ' -f 2 ; tput sgr0`
2008-04-28 10:40:55 +00:00
else
2009-05-06 09:24:34 +00:00
FINAL_URL = ` tput setaf 1; grep "SUCCESS:" $TEMPDIR /wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p' ; tput sgr0`
2008-04-28 10:40:55 +00:00
fi
2009-05-06 09:24:34 +00:00
else
if [ [ -z $PASTEBIN ] ] ; then
FINAL_URL = ` grep "SUCCESS:" $TEMPDIR /wget.tmp | cut -d ' ' -f 2`
2008-07-21 10:11:54 +00:00
else
2009-05-06 09:24:34 +00:00
FINAL_URL = ` grep "SUCCESS:" $TEMPDIR /wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p' `
2008-07-21 10:11:54 +00:00
fi
2008-04-28 10:40:55 +00:00
fi
2009-05-06 09:24:34 +00:00
#Output the URL of the uploaded file.
2008-04-28 10:40:55 +00:00
echo " Your ALSA information is located at $FINAL_URL "
echo "Please inform the person helping you."
echo ""
#We couldnt find a suitable wget, so tell the user to upload manually.
else
2009-09-03 11:00:49 +00:00
mv -f $FILE $NFILE || exit 1
KEEP_OUTPUT = "yes"
2008-04-28 10:40:55 +00:00
if [ [ -z $DIALOG ] ]
then
2008-09-11 09:03:42 +00:00
if [ [ -z $PASTEBIN ] ] ; then
echo ""
echo "Could not automatically upload output to http://www.alsa-project.org"
echo "Possible reasons are:"
echo " 1. Couldnt find 'wget' in your PATH"
echo " 2. Your version of wget is less than 1.8.2"
echo ""
2009-02-09 13:44:38 +00:00
echo " Please manually upload $NFILE to http://www.alsa-project.org/cardinfo-db/ and submit your post. "
2008-09-11 09:03:42 +00:00
echo ""
else
2008-04-28 10:40:55 +00:00
echo ""
echo "Could not automatically upload output to http://www.pastebin.ca"
echo "Possible reasons are:"
echo " 1. Couldnt find 'wget' in your PATH"
echo " 2. Your version of wget is less than 1.8.2"
echo ""
2009-02-09 13:44:38 +00:00
echo " Please manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post. "
2008-04-28 10:40:55 +00:00
echo ""
2008-09-11 09:03:42 +00:00
fi
2009-05-06 09:24:34 +00:00
else
2008-09-11 09:03:42 +00:00
if [ [ -z $PASTEBIN ] ] ; then
2009-02-09 13:44:38 +00:00
dialog --backtitle " $BGTITLE " --msgbox " Could not automatically upload output to http://www.alsa-project.org.\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 $NFILE to http://www.alsa-project,org/cardinfo-db/ and submit your post. " 25 100
2008-09-11 09:03:42 +00:00
else
2009-02-09 13:44:38 +00:00
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 $NFILE to http://www.pastebin.ca/upload.php and submit your post. " 25 100
2008-09-11 09:03:42 +00:00
fi
2008-04-28 10:40:55 +00:00
fi
fi
2009-05-06 09:24:34 +00:00