bug fixes, output fixes, error fixes

This commit is contained in:
inxi-svn 2009-07-27 05:53:29 +00:00
parent 0c198e1c74
commit c70c18e707

30
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.0.83-b1 #### version: 1.0.84-b1
#### Date: 26 July 2009 #### Date: 26 July 2009
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -551,8 +551,6 @@ initialize_script_data()
if [[ -n $( which sensors ) ]];then if [[ -n $( which sensors ) ]];then
B_SENSORS='true' B_SENSORS='true'
else
A_SENSORS_DATA=( "Sensors tool requires missing app: lm-sensors" )
fi fi
if [[ -n $DISPLAY ]];then if [[ -n $DISPLAY ]];then
@ -3013,8 +3011,8 @@ get_sensors_data()
{ {
eval $LOGFS eval $LOGFS
if [[ $B_SENSORS == 'true' ]];then
IFS="," IFS=","
if [[ $B_SENSORS == 'true' ]];then
A_SENSORS_DATA=( $( sensors | gawk ' A_SENSORS_DATA=( $( sensors | gawk '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
@ -3042,17 +3040,22 @@ get_sensors_data()
} }
END { END {
if ( moboTemp != "" && cpuTemp != "" && cpuFan != "" ) { # if they are ALL null, print error message
print moboTemp "," cpuTemp "," cpuFan if ( moboTemp == "" && cpuTemp == "" && cpuFan == "" ) {
print "No active sensors found. Have you configured your sensors yet?"
} }
else { else {
print "No sensors found. Have you configured your sensors yet?" print moboTemp "," cpuTemp "," cpuFan
} }
} }
' '
) ) ) )
IFS="$ORIGINAL_IFS" # the error case needs to go here because we are setting special array delimiter ','
else
A_SENSORS_DATA=( "You do not have the sensors app installed." )
fi fi
IFS="$ORIGINAL_IFS"
log_function_data "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}" log_function_data "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}"
echo "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}" echo "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}"
eval $LOGFE eval $LOGFE
@ -3915,15 +3918,16 @@ print_sensors_data()
local mobo_temp='' cpu_temp='' cpu_fan='' sensors_data='' local mobo_temp='' cpu_temp='' cpu_fan='' sensors_data=''
get_sensors_data get_sensors_data
# initial error cases, for missing app or unconfigured sensors
if [[ ${#A_SENSORS_DATA[@]} -eq 1 ]];then if [[ ${#A_SENSORS_DATA[@]} -eq 1 ]];then
sensors_data=${A_SENSORS_DATA[0]} mobo_temp=${A_SENSORS_DATA[0]}
else else
if [[ -n ${A_SENSORS_DATA[0]} ]];then if [[ -n ${A_SENSORS_DATA[0]} ]];then
mobo_temp=${A_SENSORS_DATA[0]} mobo_temp=${A_SENSORS_DATA[0]}
else else
mobo_temp='N/A' mobo_temp='N/A'
fi fi
mobo_temp="${C1}Mobo Temp:${C2} $mobo_temp" mobo_temp="${C1}Mobo Temp:${C2} $mobo_temp "
if [[ -n ${A_SENSORS_DATA[1]} ]];then if [[ -n ${A_SENSORS_DATA[1]} ]];then
cpu_temp=${A_SENSORS_DATA[1]} cpu_temp=${A_SENSORS_DATA[1]}
@ -3933,14 +3937,14 @@ print_sensors_data()
cpu_temp="${C1}Cpu Temp:${C2} $cpu_temp" cpu_temp="${C1}Cpu Temp:${C2} $cpu_temp"
if [[ -n ${A_SENSORS_DATA[2]} ]];then if [[ -n ${A_SENSORS_DATA[2]} ]];then
cpu_fan="${A_SENSORS_DATA[2]}rpm" cpu_fan="${A_SENSORS_DATA[2]}rpm "
else else
cpu_fan='N/A' cpu_fan='N/A'
fi fi
cpu_fan="${C1}Cpu Fan:${C2} $cpu_fan" cpu_fan="${C1}Cpu Fan:${C2} $cpu_fan "
sensors_data=${A_SENSORS_DATA[0]} sensors_data=${A_SENSORS_DATA[0]}
fi fi
sensors_data="$mobo_temp $cpu_temp $cpu_fan" sensors_data="$mobo_temp$cpu_temp$cpu_fan"
sensors_data=$( create_print_line "Sensors:" "$sensors_data" ) sensors_data=$( create_print_line "Sensors:" "$sensors_data" )
print_screen_output "$sensors_data" print_screen_output "$sensors_data"
eval $LOGFE eval $LOGFE