1#!/bin/bash 2 3# This file is part of PulseAudio. 4# 5# Copyright 2019 Russell Treleaven <rtreleaven@bunnykick.ca> 6# 7# PulseAudio is free software; you can redistribute it and/or modify 8# it under the terms of the GNU Lesser General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# PulseAudio is distributed in the hope that it will be useful, but 13# WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# General Public License for more details. 16# 17# You should have received a copy of the GNU Lesser General Public License 18# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 19 20export LC_ALL=C 21header='________________' 22function cards_get { 23 local line 24 local re='/proc/asound/card([0-9])' 25 local cards=() 26 while read -r line; do 27 [[ $line =~ $re ]] && cards+="${BASH_REMATCH[1]} " 28 done <<< "$(ls --directory /proc/asound/card[0-9])" 29 echo $cards 30} 31function jacks_do { 32 local cards=($(cards_get)) 33 for card in "${cards[@]}" ; do 34 echo "card=$card" 35 while read -r line; do 36 [[ $line != "" ]] && amixer -c$card cget "$line"; 37 done <<< "$(amixer -c$card controls | grep Jack)" 38 done 39} 40function alsa_info_do { 41 alsa_info=$(which alsa-info.sh) 42 [ $alsa_info ] || alsa_info=$(which alsa-info) 43 [ $alsa_info ] || alsa_info='/usr/sbin/alsa-info.sh' 44 [ $alsa_info ] || alsa_info='/usr/share/alsa-base/alsa-info.sh' 45 [ -f $alsa_info ] && { 46 $alsa_info --stdout 47 return 48 } 49 echo "neither alsa-info.sh or alsa-info were found" 50} 51function pulseaudio_ps_do { 52 ps aux | grep pulseaudio 53} 54function cmd_do { 55 echo "$header" 56 echo "> $1" 57 $1 58} 59function dot_d_files { 60 local files=$1 61 if ls -d1 "$files" 2> /dev/null; then 62 for fn in $files; do 63 cmd_do "cat $fn"; 64 done 65 fi 66} 67cmds=( 68 'pulseaudio_ps_do' 69 'which pulseaudio' 70 'pidof pulseaudio' 71 'pulseaudio --version' 72 'pactl info' 73 'pactl list' 74 'cat /etc/pulse/daemon.conf' 75 'cat /etc/pulse/client.conf' 76 'dot_d_files /etc/pulse/client.conf.d/*.conf' 77 'cat /etc/pulse/default.pa' 78 'dot_d_files /etc/pulse/default.pa.d/*.pa' 79 'cat /etc/pulse/system.pa' 80 'ls -alt /dev/snd/*' 81 'lsof /dev/snd/*' 82 'jacks_do' 83 'aplay -L' 84 'arecord -L' 85 'alsa_info_do' 86) 87for cmd in "${cmds[@]}" ; do 88 cmd_do "$cmd" 89done 90