1#!/bin/bash 2 3SCRIPT_VERSION=0.5.1 4CHANGELOG="https://www.alsa-project.org/alsa-info.sh.changelog" 5 6################################################################################# 7#Copyright (C) 2007 Free Software Foundation. 8 9#This program is free software; you can redistribute it and/or modify 10#it under the terms of the GNU General Public License as published by 11#the Free Software Foundation; either version 2 of the License, or 12#(at your option) any later version. 13 14#This program is distributed in the hope that it will be useful, 15#but WITHOUT ANY WARRANTY; without even the implied warranty of 16#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17#GNU General Public License for more details. 18 19#You should have received a copy of the GNU General Public License 20#along with this program; if not, write to the Free Software 21#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 23################################################################################## 24 25# The script was written for 2 main reasons: 26# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user. 27# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them. 28 29#Set the locale (this may or may not be a good idea.. let me know) 30export LC_ALL=C 31 32# Change the PATH variable, so we can run lspci (needed for some distros) 33PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin 34BGTITLE="ALSA-Info v $SCRIPT_VERSION" 35PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc" 36 37WGET=$(command -v wget) 38REQUIRES="mktemp grep pgrep awk date uname cat sort dmesg amixer alsactl" 39 40# 41# Define some simple functions 42# 43 44update() { 45 test -z "$WGET" -o ! -x "$WGET" && return 46 47 SHFILE=$(mktemp -t alsa-info.XXXXXXXXXX) || exit 1 48 wget -O $SHFILE "https://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1 49 REMOTE_VERSION=$(grep SCRIPT_VERSION $SHFILE | head -n1 | sed 's/.*=//') 50 if [ -s "$SHFILE" -a "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then 51 if [[ -n $DIALOG ]] 52 then 53 OVERWRITE= 54 if [ -w $0 ]; then 55 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 56 DIALOG_EXIT_CODE=$? 57 if [[ $DIALOG_EXIT_CODE = 0 ]]; then 58 OVERWRITE=yes 59 fi 60 fi 61 if [ -z "$OVERWRITE" ]; then 62 dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to download it?" 0 0 63 DIALOG_EXIT_CODE=$? 64 fi 65 if [[ $DIALOG_EXIT_CODE = 0 ]] 66 then 67 echo "Newer version detected: $REMOTE_VERSION" 68 echo "To view the ChangeLog, please visit $CHANGELOG" 69 if [ "$OVERWRITE" = "yes" ]; then 70 cp $SHFILE $0 71 echo "ALSA-Info script has been updated to v $REMOTE_VERSION" 72 echo "Please re-run the script" 73 rm $SHFILE 2>/dev/null 74 else 75 echo "ALSA-Info script has been downloaded as $SHFILE." 76 echo "Please re-run the script from new location." 77 fi 78 exit 79 else 80 rm $SHFILE 2>/dev/null 81 fi 82 else 83 echo "Newer version detected: $REMOTE_VERSION" 84 echo "To view the ChangeLog, please visit $CHANGELOG" 85 if [ -w $0 ]; then 86 echo "The original file $0 will be overwritten!" 87 echo -n "If you do not like to proceed, press Ctrl-C now.." ; read inp 88 cp $SHFILE $0 89 echo "ALSA-Info script has been updated. Please re-run it." 90 rm $SHFILE 2>/dev/null 91 else 92 echo "ALSA-Info script has been downloaded $SHFILE." 93 echo "Please, re-run it from new location." 94 fi 95 exit 96 fi 97 else 98 rm $SHFILE 2>/dev/null 99 fi 100} 101 102cleanup() { 103 if [ -n "$TEMPDIR" -a "$KEEP_FILES" != "yes" ]; then 104 rm -rf "$TEMPDIR" 2>/dev/null 105 fi 106 test -n "$KEEP_OUTPUT" || rm -f "$NFILE" 107} 108 109 110withaplay() { 111 echo "!!Aplay/Arecord output" >> $FILE 112 echo "!!--------------------" >> $FILE 113 echo "" >> $FILE 114 echo "APLAY" >> $FILE 115 echo "" >> $FILE 116 aplay -l >> $FILE 2>&1 117 echo "" >> $FILE 118 echo "ARECORD" >> $FILE 119 echo "" >> $FILE 120 arecord -l >> $FILE 2>&1 121 echo "" >> $FILE 122} 123 124withmodules() { 125 echo "!!All Loaded Modules" >> $FILE 126 echo "!!------------------" >> $FILE 127 echo "" >> $FILE 128 awk '{print $1}' < /proc/modules | sort >> $FILE 129 echo "" >> $FILE 130 echo "" >> $FILE 131} 132 133withamixer() { 134 echo "!!Amixer output" >> $FILE 135 echo "!!-------------" >> $FILE 136 echo "" >> $FILE 137 for f in /proc/asound/card*/id; do 138 [ -f "$f" ] && read -r CARD_NAME < "$f" || continue 139 echo "!!-------Mixer controls for card $CARD_NAME" >> $FILE 140 echo "" >>$FILE 141 amixer -c "$CARD_NAME" info >> $FILE 2>&1 142 amixer -c "$CARD_NAME" >> $FILE 2>&1 143 echo "" >> $FILE 144 done 145 echo "" >> $FILE 146} 147 148withalsactl() { 149 echo "!!Alsactl output" >> $FILE 150 echo "!!--------------" >> $FILE 151 echo "" >> $FILE 152 alsactl -f $TEMPDIR/alsactl.tmp store 153 echo "--startcollapse--" >> $FILE 154 cat $TEMPDIR/alsactl.tmp >> $FILE 155 echo "--endcollapse--" >> $FILE 156 echo "" >> $FILE 157 echo "" >> $FILE 158} 159 160withdevices() { 161 echo "!!ALSA Device nodes" >> $FILE 162 echo "!!-----------------" >> $FILE 163 echo "" >> $FILE 164 ls -la /dev/snd/* >> $FILE 165 echo "" >> $FILE 166 echo "" >> $FILE 167} 168 169withconfigs() { 170if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]; then 171 echo "!!ALSA configuration files" >> $FILE 172 echo "!!------------------------" >> $FILE 173 echo "" >> $FILE 174 175 #Check for ~/.asoundrc 176 if [[ -e $HOME/.asoundrc ]] 177 then 178 echo "!!User specific config file (~/.asoundrc)" >> $FILE 179 echo "" >> $FILE 180 cat $HOME/.asoundrc >> $FILE 181 echo "" >> $FILE 182 echo "" >> $FILE 183 fi 184 #Check for .asoundrc.asoundconf (seems to be Ubuntu specific) 185 if [[ -e $HOME/.asoundrc.asoundconf ]] 186 then 187 echo "!!asoundconf-generated config file" >> $FILE 188 echo "" >> $FILE 189 cat $HOME/.asoundrc.asoundconf >> $FILE 190 echo "" >> $FILE 191 echo "" >> $FILE 192 fi 193 #Check for /etc/asound.conf 194 if [[ -e /etc/asound.conf ]] 195 then 196 echo "!!System wide config file (/etc/asound.conf)" >> $FILE 197 echo "" >> $FILE 198 cat /etc/asound.conf >> $FILE 199 echo "" >> $FILE 200 echo "" >> $FILE 201 fi 202fi 203} 204 205withsysfs() { 206 local i f 207 local printed="" 208 for i in /sys/class/sound/*; do 209 case "$i" in 210 */hwC?D?) 211 if [ -f $i/init_pin_configs ]; then 212 if [ -z "$printed" ]; then 213 echo "!!Sysfs Files" >> $FILE 214 echo "!!-----------" >> $FILE 215 echo "" >> $FILE 216 fi 217 for f in init_pin_configs driver_pin_configs user_pin_configs init_verbs hints; do 218 echo "$i/$f:" >> $FILE 219 cat $i/$f >> $FILE 220 echo >> $FILE 221 done 222 printed=yes 223 fi 224 ;; 225 esac 226 done 227 if [ -n "$printed" ]; then 228 echo "" >> $FILE 229 fi 230} 231 232withdmesg() { 233 echo "!!ALSA/HDA dmesg" >> $FILE 234 echo "!!--------------" >> $FILE 235 echo "" >> $FILE 236 dmesg | grep -C1 -E 'ALSA|HDA|HDMI|snd[_-]|sound|audio|hda.codec|hda.intel' >> $FILE 237 echo "" >> $FILE 238 echo "" >> $FILE 239} 240 241withpackages() { 242 local RPM 243 local DPKG 244 RPM="$(command -v rpmquery)" 245 DPKG="$(command -v dpkg)" 246 [ -n "$RPM$DPKG" ] || return 247 local PATTERN='(alsa-(lib|oss|plugins|tools|(topology|ucm)-conf|utils|sof-firmware)|libalsa|tinycompress|sof-firmware)' 248 { 249 echo "!!Packages installed" 250 echo "!!--------------------" 251 echo "" 252 { 253 if [ -x "$RPM" ]; then "$RPM" -a; fi 254 if [ -x "$DPKG" ]; then "$DPKG" -l; fi 255 } | grep -E "$PATTERN" 256 echo "" 257 } >> "$FILE" 258} 259 260withall() { 261 withdevices 262 withconfigs 263 withaplay 264 withamixer 265 withalsactl 266 withmodules 267 withsysfs 268 withdmesg 269 withpackages 270 WITHALL="no" 271} 272 273get_alsa_library_version() { 274 ALSA_LIB_VERSION=$(grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null | awk '{ print $3 }' | sed 's/"//g') 275 276 if [ -z "$ALSA_LIB_VERSION" ]; then 277 if [ -f /etc/lsb-release ]; then 278 . /etc/lsb-release 279 case "$DISTRIB_ID" in 280 Ubuntu) 281 if command -v dpkg > /dev/null ; then 282 ALSA_LIB_VERSION=$(dpkg -l libasound2 | tail -1 | awk '{ print $3 }' | cut -f 1 -d -) 283 fi 284 285 if [ "$ALSA_LIB_VERSION" = "<none>" ]; then 286 ALSA_LIB_VERSION="" 287 fi 288 return 289 ;; 290 *) 291 return 292 ;; 293 esac 294 elif [ -f /etc/debian_version ]; then 295 if command -v dpkg > /dev/null ; then 296 ALSA_LIB_VERSION=$(dpkg -l libasound2 | tail -1 | awk '{ print $3 }' | cut -f 1 -d -) 297 fi 298 299 if [ "$ALSA_LIB_VERSION" = "<none>" ]; then 300 ALSA_LIB_VERSION="" 301 fi 302 return 303 fi 304 fi 305} 306 307# Basic requires 308for prg in $REQUIRES; do 309 t=$(command -v $prg) 310 if test -z "$t"; then 311 echo "This script requires $prg utility to continue." 312 exit 1 313 fi 314done 315 316# Run checks to make sure the programs we need are installed. 317LSPCI="$(command -v lspci)" 318TPUT="$(command -v tput)" 319DIALOG="$(command -v dialog)" 320 321# Check to see if sysfs is enabled in the kernel. We'll need this later on 322SYSFS=$(mount | grep sysfs | awk '{ print $3 }'); 323 324# Check modprobe config files for sound related options 325SNDOPTIONS=$(modprobe -c | sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p') 326 327KEEP_OUTPUT= 328NFILE="" 329 330PASTEBIN="" 331WWWSERVICE="www.alsa-project.org" 332WELCOME="yes" 333PROCEED="yes" 334UPLOAD="ask" 335REPEAT="" 336while [ -z "$REPEAT" ]; do 337REPEAT="no" 338case "$1" in 339 --update|--help|--about) 340 WELCOME="no" 341 PROCEED="no" 342 ;; 343 --upload) 344 UPLOAD="yes" 345 WELCOME="no" 346 ;; 347 --no-upload) 348 UPLOAD="no" 349 WELCOME="no" 350 ;; 351 --pastebin) 352 PASTEBIN="yes" 353 WWWSERVICE="pastebin" 354 ;; 355 --no-dialog) 356 DIALOG="" 357 REPEAT="" 358 shift 359 ;; 360 --stdout) 361 DIALOG="" 362 WELCOME="no" 363 ;; 364esac 365done 366 367 368#Script header output. 369if [ "$WELCOME" = "yes" ]; then 370greeting_message="\ 371 372This script visits the following commands/files to collect diagnostic 373information about your ALSA installation and sound related hardware. 374 375 dmesg 376 lspci 377 aplay 378 amixer 379 alsactl 380 rpm, dpkg 381 /proc/asound/ 382 /sys/class/sound/ 383 ~/.asoundrc (etc.) 384 385See '$0 --help' for command line options. 386" 387if [ -n "$DIALOG" ]; then 388 dialog --backtitle "$BGTITLE" \ 389 --title "ALSA-Info script v $SCRIPT_VERSION" \ 390 --msgbox "$greeting_message" 20 80 391else 392 echo "ALSA Information Script v $SCRIPT_VERSION" 393 echo "--------------------------------" 394 echo "$greeting_message" 395fi # dialog 396fi # WELCOME 397 398# Set the output file 399TEMPDIR=$(mktemp -t -d alsa-info.XXXXXXXXXX) || exit 1 400FILE="$TEMPDIR/alsa-info.txt" 401if [ -z "$NFILE" ]; then 402 NFILE=$(mktemp -t alsa-info.txt.XXXXXXXXXX) || exit 1 403fi 404 405trap cleanup 0 406 407if [ "$PROCEED" = "yes" ]; then 408 409if [ -z "$LSPCI" ]; then 410 if [ -d /sys/bus/pci ]; then 411 echo "This script requires lspci. Please install it, and re-run this script." 412 fi 413fi 414 415# Fetch the info and store in temp files/variables 416TSTAMP=$(LANG=C TZ=UTC date) 417DISTRO=$(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\|ALT" /etc/{issue,*release,*version}) 418KERNEL_VERSION=$(uname -r) 419KERNEL_PROCESSOR=$(uname -p) 420KERNEL_MACHINE=$(uname -m) 421KERNEL_OS=$(uname -o) 422[[ $(uname -v | grep SMP) ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" 423ALSA_DRIVER_VERSION=$(cat /proc/asound/version | head -n1 | awk '{ print $7 }' | sed 's/\.$//') 424get_alsa_library_version 425ALSA_UTILS_VERSION=$(amixer -v | awk '{ print $3 }') 426 427ESDINST=$(command -v esd) 428PWINST=$(command -v pipewire) 429PAINST=$(command -v pulseaudio) 430ARTSINST=$(command -v artsd) 431JACKINST=$(command -v jackd) 432JACK2INST=$(command -v jackdbus) 433ROARINST=$(command -v roard) 434DMIDECODE=$(command -v dmidecode) 435 436#Check for DMI data 437if [ -d /sys/class/dmi/id ]; then 438 # No root privileges are required when using sysfs method 439 DMI_SYSTEM_MANUFACTURER=$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null) 440 DMI_SYSTEM_PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null) 441 DMI_SYSTEM_PRODUCT_VERSION=$(cat /sys/class/dmi/id/product_version 2>/dev/null) 442 DMI_SYSTEM_FIRMWARE_VERSION=$(cat /sys/class/dmi/id/bios_version 2>/dev/null) 443 DMI_SYSTEM_SKU=$(cat /sys/class/dmi/id/product_sku 2>/dev/null) 444 DMI_BOARD_VENDOR=$(cat /sys/class/dmi/id/board_vendor 2>/dev/null) 445 DMI_BOARD_NAME=$(cat /sys/class/dmi/id/board_name 2>/dev/null) 446elif [ -x $DMIDECODE ]; then 447 DMI_SYSTEM_MANUFACTURER=$($DMIDECODE -s system-manufacturer 2>/dev/null) 448 DMI_SYSTEM_PRODUCT_NAME=$($DMIDECODE -s system-product-name 2>/dev/null) 449 DMI_SYSTEM_PRODUCT_VERSION=$($DMIDECODE -s system-version 2>/dev/null) 450 DMI_SYSTEM_FIRMWARE_VERSION=$($DMIDECODE -s bios-version 2>/dev/null) 451 DMI_SYSTEM_SKU=$($DMIDECODE -s system-sku-number 2>/dev/null) 452 DMI_BOARD_VENDOR=$($DMIDECODE -s baseboard-manufacturer 2>/dev/null) 453 DMI_BOARD_NAME=$($DMIDECODE -s baseboard-product-name 2>/dev/null) 454fi 455 456# Check for ACPI device status 457if [ -d /sys/bus/acpi/devices ]; then 458 for f in /sys/bus/acpi/devices/*/status; do 459 ACPI_STATUS=$(cat $f 2>/dev/null); 460 if [[ "$ACPI_STATUS" -ne 0 ]]; then 461 echo $f $'\t' $ACPI_STATUS >>$TEMPDIR/acpidevicestatus.tmp; 462 fi 463 done 464fi 465 466awk '{ print $2 " (card " $1 ")" }' < /proc/asound/modules > $TEMPDIR/alsamodules.tmp 2> /dev/null 467cat /proc/asound/cards > $TEMPDIR/alsacards.tmp 468if [[ ! -z "$LSPCI" ]]; then 469 for class in 0401 0402 0403; do 470 lspci -vvnn -d "::$class" | sed -n '/^[^\t]/,+1p' 471 done > $TEMPDIR/lspci.tmp 472fi 473 474#Check for HDA-Intel cards codec#* 475cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null 476 477#Check for AC97 cards codec 478cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null 479cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null 480 481#Check for USB descriptors 482if [ -x /usr/bin/lsusb ]; then 483 for f in /proc/asound/card[0-9]*/usbbus; do 484 test -f "$f" || continue 485 id=$(sed 's@/@:@' $f) 486 lsusb -v -s $id >> $TEMPDIR/lsusb.tmp 2> /dev/null 487 done 488fi 489 490#Check for USB stream setup 491cat /proc/asound/card*/stream[0-9]* > $TEMPDIR/alsa-usbstream.tmp 2> /dev/null 492 493#Check for USB mixer setup 494cat /proc/asound/card*/usbmixer > $TEMPDIR/alsa-usbmixer.tmp 2> /dev/null 495 496#Fetch the info, and put it in $FILE in a nice readable format. 497if [[ -z $PASTEBIN ]]; then 498echo "upload=true&script=true&cardinfo=" > $FILE 499else 500echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE 501fi 502echo "!!################################" >> $FILE 503echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE 504echo "!!################################" >> $FILE 505echo "" >> $FILE 506echo "!!Script ran on: $TSTAMP" >> $FILE 507echo "" >> $FILE 508echo "" >> $FILE 509echo "!!Linux Distribution" >> $FILE 510echo "!!------------------" >> $FILE 511echo "" >> $FILE 512echo $DISTRO >> $FILE 513echo "" >> $FILE 514echo "" >> $FILE 515echo "!!DMI Information" >> $FILE 516echo "!!---------------" >> $FILE 517echo "" >> $FILE 518echo "Manufacturer: $DMI_SYSTEM_MANUFACTURER" >> $FILE 519echo "Product Name: $DMI_SYSTEM_PRODUCT_NAME" >> $FILE 520echo "Product Version: $DMI_SYSTEM_PRODUCT_VERSION" >> $FILE 521echo "Firmware Version: $DMI_SYSTEM_FIRMWARE_VERSION" >> $FILE 522echo "System SKU: $DMI_SYSTEM_SKU" >> $FILE 523echo "Board Vendor: $DMI_BOARD_VENDOR" >> $FILE 524echo "Board Name: $DMI_BOARD_NAME" >> $FILE 525echo "" >> $FILE 526echo "" >> $FILE 527echo "!!ACPI Device Status Information" >> $FILE 528echo "!!---------------" >> $FILE 529echo "" >> $FILE 530cat $TEMPDIR/acpidevicestatus.tmp >> $FILE 531echo "" >> $FILE 532echo "" >> $FILE 533echo "!!Kernel Information" >> $FILE 534echo "!!------------------" >> $FILE 535echo "" >> $FILE 536echo "Kernel release: $KERNEL_VERSION" >> $FILE 537echo "Operating System: $KERNEL_OS" >> $FILE 538echo "Architecture: $KERNEL_MACHINE" >> $FILE 539echo "Processor: $KERNEL_PROCESSOR" >> $FILE 540echo "SMP Enabled: $KERNEL_SMP" >> $FILE 541echo "" >> $FILE 542echo "" >> $FILE 543echo "!!ALSA Version" >> $FILE 544echo "!!------------" >> $FILE 545echo "" >> $FILE 546echo "Driver version: $ALSA_DRIVER_VERSION" >> $FILE 547echo "Library version: $ALSA_LIB_VERSION" >> $FILE 548echo "Utilities version: $ALSA_UTILS_VERSION" >> $FILE 549echo "" >> $FILE 550echo "" >> $FILE 551echo "!!Loaded ALSA modules" >> $FILE 552echo "!!-------------------" >> $FILE 553echo "" >> $FILE 554cat $TEMPDIR/alsamodules.tmp >> $FILE 555echo "" >> $FILE 556echo "" >> $FILE 557echo "!!Sound Servers on this system" >> $FILE 558echo "!!----------------------------" >> $FILE 559echo "" >> $FILE 560if [[ -n $PWINST ]];then 561[[ $(pgrep '^(.*/)?pipewire$') ]] && PWRUNNING="Yes" || PWRUNNING="No" 562echo "PipeWire:" >> $FILE 563echo " Installed - Yes ($PWINST)" >> $FILE 564echo " Running - $PWRUNNING" >> $FILE 565echo "" >> $FILE 566fi 567if [[ -n $PAINST ]];then 568[[ $(pgrep '^(.*/)?pulseaudio$') ]] && PARUNNING="Yes" || PARUNNING="No" 569echo "Pulseaudio:" >> $FILE 570echo " Installed - Yes ($PAINST)" >> $FILE 571echo " Running - $PARUNNING" >> $FILE 572echo "" >> $FILE 573fi 574if [[ -n $ESDINST ]];then 575[[ $(pgrep '^(.*/)?esd$') ]] && ESDRUNNING="Yes" || ESDRUNNING="No" 576echo "ESound Daemon:" >> $FILE 577echo " Installed - Yes ($ESDINST)" >> $FILE 578echo " Running - $ESDRUNNING" >> $FILE 579echo "" >> $FILE 580fi 581if [[ -n $ARTSINST ]];then 582[[ $(pgrep '^(.*/)?artsd$') ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No" 583echo "aRts:" >> $FILE 584echo " Installed - Yes ($ARTSINST)" >> $FILE 585echo " Running - $ARTSRUNNING" >> $FILE 586echo "" >> $FILE 587fi 588if [[ -n $JACKINST ]];then 589[[ $(pgrep '^(.*/)?jackd$') ]] && JACKRUNNING="Yes" || JACKRUNNING="No" 590echo "Jack:" >> $FILE 591echo " Installed - Yes ($JACKINST)" >> $FILE 592echo " Running - $JACKRUNNING" >> $FILE 593echo "" >> $FILE 594fi 595if [[ -n $JACK2INST ]];then 596[[ $(pgrep '^(.*/)?jackdbus$') ]] && JACK2RUNNING="Yes" || JACK2RUNNING="No" 597echo "Jack2:" >> $FILE 598echo " Installed - Yes ($JACK2INST)" >> $FILE 599echo " Running - $JACK2RUNNING" >> $FILE 600echo "" >> $FILE 601fi 602if [[ -n $ROARINST ]];then 603[[ $(pgrep '^(.*/)?roard$') ]] && ROARRUNNING="Yes" || ROARRUNNING="No" 604echo "RoarAudio:" >> $FILE 605echo " Installed - Yes ($ROARINST)" >> $FILE 606echo " Running - $ROARRUNNING" >> $FILE 607echo "" >> $FILE 608fi 609if [[ -z "$PAINST" && -z "$ESDINST" && -z "$ARTSINST" && -z "$JACKINST" && -z "$ROARINST" ]];then 610echo "No sound servers found." >> $FILE 611echo "" >> $FILE 612fi 613echo "" >> $FILE 614echo "!!Soundcards recognised by ALSA" >> $FILE 615echo "!!-----------------------------" >> $FILE 616echo "" >> $FILE 617cat $TEMPDIR/alsacards.tmp >> $FILE 618echo "" >> $FILE 619echo "" >> $FILE 620 621if [[ ! -z "$LSPCI" ]]; then 622echo "!!PCI Soundcards installed in the system" >> $FILE 623echo "!!--------------------------------------" >> $FILE 624echo "" >> $FILE 625cat $TEMPDIR/lspci.tmp >> $FILE 626echo "" >> $FILE 627echo "" >> $FILE 628fi 629 630if [ "$SNDOPTIONS" ]; then 631echo "!!Modprobe options (Sound related)" >> $FILE 632echo "!!--------------------------------" >> $FILE 633echo "" >> $FILE 634modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' >> $FILE 635echo "" >> $FILE 636echo "" >> $FILE 637fi 638 639if [ -d "$SYSFS" ]; then 640 echo "!!Loaded sound module options" >> $FILE 641 echo "!!---------------------------" >> $FILE 642 echo "" >> $FILE 643 for mod in $(cat /proc/asound/modules | awk '{ print $2 }'); do 644 echo "!!Module: $mod" >> $FILE 645 for params in $(echo $SYSFS/module/$mod/parameters/*); do 646 echo -ne "\t" 647 value=$(cat $params) 648 echo "$params : $value" | sed 's:.*/::' 649 done >> $FILE 650 echo "" >> $FILE 651 done 652 echo "" >> $FILE 653 echo "!!Sysfs card info" >> $FILE 654 echo "!!---------------" >> $FILE 655 echo "" >> $FILE 656 for cdir in $(echo $SYSFS/class/sound/card*); do 657 echo "!!Card: $cdir" >> $FILE 658 driver=$(readlink -f "$cdir/device/driver") 659 echo "Driver: $driver" >> $FILE 660 echo "Tree:" >> $FILE 661 tree --noreport $cdir -L 2 | sed -e 's/^/\t/g' >> $FILE 662 echo "" >> $FILE 663 done 664 echo "" >> $FILE 665fi 666 667if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ]; then 668 echo "!!HDA-Intel Codec information" >> $FILE 669 echo "!!---------------------------" >> $FILE 670 echo "--startcollapse--" >> $FILE 671 echo "" >> $FILE 672 cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE 673 echo "--endcollapse--" >> $FILE 674 echo "" >> $FILE 675 echo "" >> $FILE 676fi 677 678if [ -s "$TEMPDIR/alsa-ac97.tmp" ]; then 679 echo "!!AC97 Codec information" >> $FILE 680 echo "!!----------------------" >> $FILE 681 echo "--startcollapse--" >> $FILE 682 echo "" >> $FILE 683 cat $TEMPDIR/alsa-ac97.tmp >> $FILE 684 echo "" >> $FILE 685 cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE 686 echo "--endcollapse--" >> $FILE 687 echo "" >> $FILE 688 echo "" >> $FILE 689fi 690 691if [ -s "$TEMPDIR/lsusb.tmp" ]; then 692 echo "!!USB Descriptors" >> $FILE 693 echo "!!---------------" >> $FILE 694 echo "--startcollapse--" >> $FILE 695 cat $TEMPDIR/lsusb.tmp >> $FILE 696 echo "--endcollapse--" >> $FILE 697 echo "" >> $FILE 698 echo "" >> $FILE 699fi 700 701if [ -s "$TEMPDIR/alsa-usbstream.tmp" ]; then 702 echo "!!USB Stream information" >> $FILE 703 echo "!!----------------------" >> $FILE 704 echo "--startcollapse--" >> $FILE 705 echo "" >> $FILE 706 cat $TEMPDIR/alsa-usbstream.tmp >> $FILE 707 echo "--endcollapse--" >> $FILE 708 echo "" >> $FILE 709 echo "" >> $FILE 710fi 711 712if [ -s "$TEMPDIR/alsa-usbmixer.tmp" ]; then 713 echo "!!USB Mixer information" >> $FILE 714 echo "!!---------------------" >> $FILE 715 echo "--startcollapse--" >> $FILE 716 echo "" >> $FILE 717 cat $TEMPDIR/alsa-usbmixer.tmp >> $FILE 718 echo "--endcollapse--" >> $FILE 719 echo "" >> $FILE 720 echo "" >> $FILE 721fi 722 723#If no command line options are specified, then run as though --with-all was specified 724if [ -z "$1" ]; then 725 update 726fi 727 728fi # proceed 729 730#loop through command line arguments, until none are left. 731if [ -n "$1" ]; then 732 until [ -z "$1" ] 733 do 734 case "$1" in 735 --pastebin) 736 update 737 ;; 738 --update) 739 update 740 exit 741 ;; 742 --upload) 743 UPLOAD="yes" 744 ;; 745 --no-upload) 746 UPLOAD="no" 747 ;; 748 --output) 749 shift 750 NFILE="$1" 751 KEEP_OUTPUT="yes" 752 ;; 753 --debug) 754 echo "Debugging enabled. $FILE and $TEMPDIR will not be deleted" 755 KEEP_FILES="yes" 756 echo "" 757 ;; 758 --with-all) 759 withall 760 ;; 761 --with-aplay) 762 withaplay 763 WITHALL="no" 764 ;; 765 --with-amixer) 766 withamixer 767 WITHALL="no" 768 ;; 769 --with-alsactl) 770 withalsactl 771 WITHALL="no" 772 ;; 773 --with-devices) 774 withdevices 775 WITHALL="no" 776 ;; 777 --with-dmesg) 778 withdmesg 779 WITHALL="no" 780 ;; 781 --with-configs) 782 withconfigs 783 WITHALL="no" 784 ;; 785 --with-packages) 786 withpackages 787 WITHALL="no" 788 ;; 789 --stdout) 790 UPLOAD="no" 791 if [ -z "$WITHALL" ]; then 792 withall 793 fi 794 cat $FILE 795 rm $FILE 796 exit 797 ;; 798 --about) 799 echo "Written/Tested by the following users of #alsa on irc.freenode.net:" 800 echo "" 801 echo " wishie - Script author and developer / Testing" 802 echo " crimsun - Various script ideas / Testing" 803 echo " gnubien - Various script ideas / Testing" 804 echo " GrueMaster - HDA Intel specific items / Testing" 805 echo " olegfink - Script update function" 806 echo " TheMuso - display to stdout functionality" 807 exit 0 808 ;; 809 *) 810 echo "alsa-info.sh version $SCRIPT_VERSION" 811 echo "" 812 echo "Available options:" 813 echo " --with-aplay (includes the output of aplay -l)" 814 echo " --with-amixer (includes the output of amixer)" 815 echo " --with-alsactl (includes the output of alsactl)" 816 echo " --with-configs (includes the output of ~/.asoundrc and" 817 echo " /etc/asound.conf if they exist)" 818 echo " --with-devices (shows the device nodes in /dev/snd/)" 819 echo " --with-dmesg (shows the ALSA/HDA kernel messages)" 820 echo " --with-packages (includes known packages installed)" 821 echo "" 822 echo " --output FILE (specify the file to output for no-upload mode)" 823 echo " --update (check server for script updates)" 824 echo " --upload (upload contents to remote server)" 825 echo " --no-upload (do not upload contents to remote server)" 826 echo " --pastebin (use https://pastebin.ca) as remote server" 827 echo " instead www.alsa-project.org" 828 echo " --stdout (print alsa information to standard output" 829 echo " instead of a file)" 830 echo " --about (show some information about the script)" 831 echo " --debug (will run the script as normal, but will not" 832 echo " delete $FILE)" 833 exit 0 834 ;; 835 esac 836 shift 1 837 done 838fi 839 840if [ "$PROCEED" = "no" ]; then 841 exit 1 842fi 843 844if [ -z "$WITHALL" ]; then 845 withall 846fi 847 848# Check if wget is installed, and supports --post-file. 849if ! wget --help 2>/dev/null | grep -q post-file; then 850 # We couldn't find a suitable wget. If --upload was passed, tell the user to upload manually. 851 if [ "$UPLOAD" != "yes" ]; then 852 : 853 elif [ -n "$DIALOG" ]; then 854 if [ -z "$PASTEBIN" ]; then 855 dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to https://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 https://www.alsa-project.org/cardinfo-db/ and submit your post." 25 100 856 else 857 dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to https://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 https://www.pastebin.ca/upload.php and submit your post." 25 100 858 fi 859 else 860 if [ -z "$PASTEBIN" ]; then 861 echo "" 862 echo "Could not automatically upload output to https://www.alsa-project.org" 863 echo "Possible reasons are:" 864 echo " 1. Couldn't find 'wget' in your PATH" 865 echo " 2. Your version of wget is less than 1.8.2" 866 echo "" 867 echo "Please manually upload $NFILE to https://www.alsa-project.org/cardinfo-db/ and submit your post." 868 echo "" 869 else 870 echo "" 871 echo "Could not automatically upload output to https://www.pastebin.ca" 872 echo "Possible reasons are:" 873 echo " 1. Couldn't find 'wget' in your PATH" 874 echo " 2. Your version of wget is less than 1.8.2" 875 echo "" 876 echo "Please manually upload $NFILE to https://www.pastebin.ca/upload.php and submit your post." 877 echo "" 878 fi 879 fi 880 UPLOAD="no" 881fi 882 883if [ "$UPLOAD" = "ask" ]; then 884 if [ -n "$DIALOG" ]; then 885 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 886 DIALOG_EXIT_CODE=$? 887 if [ $DIALOG_EXIT_CODE != 0 ]; then 888 UPLOAD="no" 889 else 890 UPLOAD="yes" 891 fi 892 else 893 echo -n "Automatically upload ALSA information to $WWWSERVICE? [y/N] : " 894 read -e CONFIRM 895 if [ "$CONFIRM" != "y" ]; then 896 UPLOAD="no" 897 else 898 UPLOAD="yes" 899 fi 900 fi 901 902fi 903 904if [ "$UPLOAD" = "no" ]; then 905 906 mv -f $FILE $NFILE || exit 1 907 KEEP_OUTPUT="yes" 908 909 if [[ -n $DIALOG ]] 910 then 911 dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60 912 else 913 echo "" 914 echo "Your ALSA information is in $NFILE" 915 echo "" 916 fi 917 918 exit 919 920fi # UPLOAD 921 922if [[ -n $DIALOG ]] 923then 924 dialog --backtitle "$BGTITLE" --infobox "Uploading information to $WWWSERVICE ..." 6 70 925else 926 echo -n "Uploading information to $WWWSERVICE ..." 927fi 928 929if [[ -z $PASTEBIN ]]; then 930 wget -O - --tries=5 --timeout=60 --post-file=$FILE "https://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp 931else 932 wget -O - --tries=5 --timeout=60 --post-file=$FILE "https://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>$TEMPDIR/wget.tmp 933fi 934 935if [ $? -ne 0 ]; then 936 mv -f $FILE $NFILE || exit 1 937 KEEP_OUTPUT="yes" 938 939 if [ -n "$DIALOG" ]; then 940 dialog --backtitle "$BGTITLE" --title "Information not uploaded" --msgbox "An error occurred while contacting $WWWSERVICE.\n Your information was NOT automatically uploaded.\n\nYour ALSA information is in $NFILE" 10 100 941 else 942 echo "" 943 echo "An error occurred while contacting $WWWSERVICE." 944 echo "Your information was NOT automatically uploaded." 945 echo "" 946 echo "Your ALSA information is in $NFILE" 947 echo "" 948 fi 949 950 exit 951fi 952 953if [ -n "$DIALOG" ]; then 954 955dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 956DIALOG_EXIT_CODE=$? 957if [ $DIALOG_EXIT_CODE = 0 ]; then 958 grep -v "alsa-info.txt" $FILE > $TEMPDIR/uploaded.txt 959 dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0 960fi 961 962clear 963 964# no dialog 965else 966 967echo -e " Done!" 968echo "" 969 970fi # dialog 971 972if [ -z "$PASTEBIN" ]; then 973 FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2) 974else 975 FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/https:\/\/pastebin.ca\/\1/p') 976fi 977 978# See if tput is available, and use it if it is. 979if [ -x "$TPUT" ]; then 980 FINAL_URL=$(tput setaf 1; printf '%s' "$FINAL_URL"; tput sgr0) 981fi 982 983# Output the URL of the uploaded file. 984echo "Your ALSA information is located at $FINAL_URL" 985echo "Please inform the person helping you." 986echo "" 987