From c70c18e707dd772406053a017e33d75fd5e84935 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Mon, 27 Jul 2009 05:53:29 +0000 Subject: [PATCH] bug fixes, output fixes, error fixes --- inxi | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/inxi b/inxi index a3ce3fa..4f0ddad 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.0.83-b1 +#### version: 1.0.84-b1 #### Date: 26 July 2009 ######################################################################## #### SPECIAL THANKS @@ -551,8 +551,6 @@ initialize_script_data() if [[ -n $( which sensors ) ]];then B_SENSORS='true' - else - A_SENSORS_DATA=( "Sensors tool requires missing app: lm-sensors" ) fi if [[ -n $DISPLAY ]];then @@ -3013,8 +3011,8 @@ get_sensors_data() { eval $LOGFS + IFS="," if [[ $B_SENSORS == 'true' ]];then - IFS="," A_SENSORS_DATA=( $( sensors | gawk ' BEGIN { IGNORECASE=1 @@ -3042,17 +3040,22 @@ get_sensors_data() } END { - if ( moboTemp != "" && cpuTemp != "" && cpuFan != "" ) { - print moboTemp "," cpuTemp "," cpuFan + # if they are ALL null, print error message + if ( moboTemp == "" && cpuTemp == "" && cpuFan == "" ) { + print "No active sensors found. Have you configured your sensors yet?" } 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 + + IFS="$ORIGINAL_IFS" log_function_data "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}" echo "A_SENSORS_DATA: ${A_SENSORS_DATA[@]}" eval $LOGFE @@ -3914,16 +3917,17 @@ print_sensors_data() eval $LOGFS local mobo_temp='' cpu_temp='' cpu_fan='' sensors_data='' get_sensors_data - + + # initial error cases, for missing app or unconfigured sensors if [[ ${#A_SENSORS_DATA[@]} -eq 1 ]];then - sensors_data=${A_SENSORS_DATA[0]} + mobo_temp=${A_SENSORS_DATA[0]} else if [[ -n ${A_SENSORS_DATA[0]} ]];then mobo_temp=${A_SENSORS_DATA[0]} else mobo_temp='N/A' fi - mobo_temp="${C1}Mobo Temp:${C2} $mobo_temp" + mobo_temp="${C1}Mobo Temp:${C2} $mobo_temp " if [[ -n ${A_SENSORS_DATA[1]} ]];then cpu_temp=${A_SENSORS_DATA[1]} @@ -3933,14 +3937,14 @@ print_sensors_data() cpu_temp="${C1}Cpu Temp:${C2} $cpu_temp" if [[ -n ${A_SENSORS_DATA[2]} ]];then - cpu_fan="${A_SENSORS_DATA[2]}rpm" + cpu_fan="${A_SENSORS_DATA[2]}rpm " else cpu_fan='N/A' fi - cpu_fan="${C1}Cpu Fan:${C2} $cpu_fan" + cpu_fan="${C1}Cpu Fan:${C2} $cpu_fan " sensors_data=${A_SENSORS_DATA[0]} 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" ) print_screen_output "$sensors_data" eval $LOGFE