(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

42
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 0.5.28
#### version: 0.5.29
#### Date: November 13 2008
########################################################################
#### 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
A_AUDIO_DATA=( $( gawk -F ']: ' '{
card=gensub( /^(.+)( - )(.+)$/, "\\3", 1, $2 )
print card
driver=gensub( /^(.+)( - )(.+)$/, "\\1", 1, $2 )
if ( card != "" ){
print card","driver
}
}' /proc/asound/cards ) )
fi
IFS="$ORIGINAL_IFS"
@ -1029,6 +1032,7 @@ get_audio_data()
}
}' /proc/asound/version )
fi
echo ${A_AUDIO_DATA[@]}
}
## 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()
{
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
get_audio_data
@ -1922,10 +1926,14 @@ print_audio_data()
card_one='Card '
fi
if [[ -n ${a_audio_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[1]}"
# if [[ -n ${a_audio_working[2]} ]];then
# 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
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" )
print_screen_output "$audio_data"
i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
@ -1934,18 +1942,24 @@ print_audio_data()
IFS=","
a_audio_working=( ${A_AUDIO_DATA[i]} )
IFS="$ORIGINAL_IFS"
port_data=''
if [[ ${a_audio_working[1]} == 'port' ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[2]}"
# port_data=''
alsa_driver=''
# 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
# we're testing for the presence of the 2nd array item here
if [[ ${a_audio_working[1]} != 'alsa' ]];then
audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$port_data"
else
audio_data="${C1}Sound Driver: ${C2}${a_audio_working[0]}"
if [[ -n ${a_audio_working[1]} && ${a_audio_working[1]} != 'alsa' ]];then
audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$alsa_driver$port_data"
elif [[ -n ${a_audio_working[1]} && ${a_audio_working[1]} == 'alsa' ]];then
audio_data="${C1}Sound: ${C2}${a_audio_working[0]}"
fi
if [[ -n $audio_data ]];then
audio_data=$( create_print_line " " "$audio_data" )
print_screen_output "$audio_data"
fi
done
fi
}