(change version)

This is as close as I can get to getting the alsa driver to show, but it only works if
lspci for audio comes up blank, that way we can use /proc/asound/cards for all the data
and extract the card and driver from that into an array.

But I can't see any way to match the full output of lspci if present with the card data
from /proc/asound/cards, because sometimes there is nothing in common between the two.

Maybe someone else can solve this one...
This commit is contained in:
inxi-svn 2008-11-14 03:32:47 +00:00
parent 4c5717cf81
commit 1b3b91afb0

46
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.5.28 #### version: 0.5.29
#### Date: November 13 2008 #### Date: November 13 2008
######################################################################## ########################################################################
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif #### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
@ -1004,7 +1004,10 @@ get_audio_data()
if [[ ${#A_AUDIO_DATA[@]} -eq 0 && -f /proc/asound/cards ]];then if [[ ${#A_AUDIO_DATA[@]} -eq 0 && -f /proc/asound/cards ]];then
A_AUDIO_DATA=( $( gawk -F ']: ' '{ A_AUDIO_DATA=( $( gawk -F ']: ' '{
card=gensub( /^(.+)( - )(.+)$/, "\\3", 1, $2 ) card=gensub( /^(.+)( - )(.+)$/, "\\3", 1, $2 )
print card driver=gensub( /^(.+)( - )(.+)$/, "\\1", 1, $2 )
if ( card != "" ){
print card","driver
}
}' /proc/asound/cards ) ) }' /proc/asound/cards ) )
fi fi
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
@ -1029,6 +1032,7 @@ get_audio_data()
} }
}' /proc/asound/version ) }' /proc/asound/version )
fi fi
echo ${A_AUDIO_DATA[@]}
} }
## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text ## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text
@ -1908,7 +1912,7 @@ print_short_data()
print_audio_data() print_audio_data()
{ {
local i='' card_one='Card-1 ' audio_data='' a_audio_data='' port_data='' local i='' card_one='Card-1 ' audio_data='' a_audio_data='' port_data=''
local a_audio_working='' local a_audio_working='' alsa_driver=''
# set A_AUDIO_DATA # set A_AUDIO_DATA
get_audio_data get_audio_data
@ -1922,10 +1926,14 @@ print_audio_data()
card_one='Card ' card_one='Card '
fi fi
if [[ -n ${a_audio_working[1]} ]];then # if [[ -n ${a_audio_working[2]} ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[1]}" # port_data=" ${C1}at port${C2} ${a_audio_working[2]}"
# fi
# this should only trigger if the /proc/asound/cards data is used, not lspci -nn
if [[ -n ${a_audio_working[1]} && ${a_audio_working[1]} != 'alsa' ]];then
alsa_driver=" ${C1}driver${C2} ${a_audio_working[1]}"
fi fi
audio_data="${C1}$card_one${C2}${a_audio_working[0]}$port_data" audio_data="${C1}$card_one${C2}${a_audio_working[0]}$alsa_driver$port_data"
audio_data=$( create_print_line "Audio:" "$audio_data" ) audio_data=$( create_print_line "Audio:" "$audio_data" )
print_screen_output "$audio_data" print_screen_output "$audio_data"
i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1 i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
@ -1934,18 +1942,24 @@ print_audio_data()
IFS="," IFS=","
a_audio_working=( ${A_AUDIO_DATA[i]} ) a_audio_working=( ${A_AUDIO_DATA[i]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
port_data='' # port_data=''
if [[ ${a_audio_working[1]} == 'port' ]];then alsa_driver=''
port_data=" ${C1}at port${C2} ${a_audio_working[2]}" # if [[ ${a_audio_working[2]} == 'port' ]];then
# port_data=" ${C1}at port${C2} ${a_audio_working[2]}"
# fi
# we're testing for the presence of the 2nd array item here, which is the driver name
if [[ -n ${a_audio_working[1]} && ${a_audio_working[1]} != 'alsa' ]];then
alsa_driver="${C1}driver${C2} ${a_audio_working[1]}"
fi fi
# we're testing for the presence of the 2nd array item here if [[ -n ${a_audio_working[1]} && ${a_audio_working[1]} != 'alsa' ]];then
if [[ ${a_audio_working[1]} != 'alsa' ]];then audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$alsa_driver$port_data"
audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$port_data" elif [[ -n ${a_audio_working[1]} && ${a_audio_working[1]} == 'alsa' ]];then
else audio_data="${C1}Sound: ${C2}${a_audio_working[0]}"
audio_data="${C1}Sound Driver: ${C2}${a_audio_working[0]}" fi
if [[ -n $audio_data ]];then
audio_data=$( create_print_line " " "$audio_data" )
print_screen_output "$audio_data"
fi fi
audio_data=$( create_print_line " " "$audio_data" )
print_screen_output "$audio_data"
done done
fi fi
} }