diff --git a/inxi b/inxi index f54431e..3ac24a3 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.7.1-b1-t7 -#### Date: December 3 2008 +#### version: 0.8.5-b1-t1 +#### Date: December 12 2008 ######################################################################## #### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif #### As time permits functionality improvements and recoding will occur. @@ -152,7 +152,9 @@ B_X_RUNNING='false' if [[ -n $DISPLAY ]];then B_X_RUNNING='true' fi - +if [[ $B_TESTING_1 == 'true' ]];then + echo B_X_RUNNING: $B_X_RUNNING +fi ### Variable initializations: constants DCOPOBJ="default" DEBUG=0 # Set debug levels from 1-10 @@ -1933,12 +1935,14 @@ get_partition_data() /\/$|\/boot$|\/var$|\/home$|\/tmp$|\/usr$/ && ! /aufs/ { print $NF "," $(NF - 4) "," $(NF - 3) "," $(NF - 1) ",main" } + # skip all these, including the first, header line. Use the --exclude-type + # to handle new filesystems types we do not want listed here ! /\/$|\/boot$|\/var$|\/home$|\/tmp$|\/usr$|^filesystem/ { # this is to avoid file systems with spaces in their names, that will make # the test show the wrong data in each of the fields, if no x%, then do not use if ( $(NF - 1) ~ /[0-9]+\%/ ) { # cleaning up user name here to avoid showing too much info on irc - partitionName=gensub( /^\/home\/(.*)\/(.*)/, "/home//\\2", 1, $NF ) + partitionName=gensub( /^\/home\/(.*)\/(.*)/, "/home/###/\\2", 1, $NF ) print partitionName "," $(NF - 4) "," $(NF - 3) "," $(NF - 1) ",secondary" } } @@ -2335,32 +2339,30 @@ print_cpu_data() # args: $1 - cpu flag string print_cpu_flags_full() { - local cpu_flags_full="$1" cpu_flags_1='' cpu_flags_2='' cpu_flags_3='' flag_data='' - local i=0 flag='' + local cpu_flags_full="$1" a_cpu_flags='' line_starter='' + local i=0 counter=0 max_length=18 max_length_add=18 flag='' flag_data='' + # build the flag line array for flag in $cpu_flags_full do - if [[ $i -ge 36 ]];then - cpu_flags_3="$cpu_flags_3$flag " - elif [[ $i -ge 18 ]];then - cpu_flags_2="$cpu_flags_2$flag " - elif [[ $i -ge 0 ]];then - cpu_flags_1="$cpu_flags_1$flag " + a_cpu_flags[$counter]="${a_cpu_flags[$counter]}$flag " + if [[ $i -ge $max_length ]];then + (( counter++ )) + max_length=$(( $max_length + $max_length_add )) fi ((i++)) done - if [[ -n $cpu_flags_1 ]];then - flag_data=$( create_print_line " " "${C1}CPU Flags${C2} $cpu_flags_1" ) + # then print it out + for (( i=0; i < ${#a_cpu_flags[@]};i++ )) + do + if [[ $i -eq 0 ]];then + line_starter="${C1}CPU Flags${C2} " + else + line_starter='' + fi + flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" ) print_screen_output "$flag_data" - fi - if [[ -n $cpu_flags_2 ]];then - flag_data=$( create_print_line " " "$cpu_flags_2" ) - print_screen_output "$flag_data" - fi - if [[ -n $cpu_flags_3 ]];then - flag_data=$( create_print_line " " "$cpu_flags_3" ) - print_screen_output "$flag_data" - fi + done } print_gfx_data() @@ -2405,7 +2407,7 @@ print_gfx_data() ## note: if glx render or version have no content, then mesa is true if [[ $B_X_RUNNING == 'true' && $b_is_mesa != 'true' ]];then - gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${glx_renderer} ${CN}| ${C1}GLX Version${C2} ${glx_version}${CN}" ) + gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${glx_renderer} ${C1}GLX Version${C2} ${glx_version}${CN}" ) if [[ $B_HANDLE_CORRUPT_DATA == 'true' ]];then gfx_data="${gfx_data} ${C1}Direct rendering${C2} ${glx_direct_render}${CN}" fi @@ -2624,14 +2626,17 @@ print_networking_ip_data() print_partition_data() { - local a_partition_working='' partition_used='' swap='' partition_data='' partition_data_2='' - local partition_data_3='' partition_data_4='' partition_data_5='' partition_data_6='' - local partition_data_7='' partition_data_8='' counter=1 line_max=160 + local a_partition_working='' partition_used='' swap='' partition_data='' + local counter=0 line_max=160 i=0 a_partition_data='' line_starter='' # this handles the different, shorter, irc colors strings embedded in variable data if [[ $B_RUNNING_IN_SHELL != 'true' ]];then line_max=130 fi + # and no color string data at all + if [[ $SCHEME -eq 0 ]];then + line_max=75 + fi # set A_PARTITION_DATA get_partition_data @@ -2654,88 +2659,23 @@ print_partition_data() swap='' fi # because these lines can vary widely, using dynamic length handling here - case $counter in - 1) - partition_data="$partition_data${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data ) -gt $line_max ]];then - counter=2 - fi - ;; - 2) - partition_data_2="$partition_data_2${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data_2 ) -gt $line_max ]];then - counter=3 - fi - ;; - 3) - partition_data_3="$partition_data_3${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data_3 ) -gt $line_max ]];then - counter=4 - fi - ;; - 4) - partition_data_4="$partition_data_4${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data_4 ) -gt $line_max ]];then - counter=5 - fi - ;; - 5) - partition_data_5="$partition_data_5${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data_5 ) -gt $line_max ]];then - counter=6 - fi - ;; - 6) - partition_data_6="$partition_data_6${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data_6 ) -gt $line_max ]];then - counter=7 - fi - ;; - 7) - partition_data_7="$partition_data_7${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - if [[ $( wc -c <<< $partition_data_7 ) -gt $line_max ]];then - counter=8 - fi - ;; - *) - partition_data_8="$partition_data_8${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " - ;; - esac + a_partition_data[$counter]="${a_partition_data[$counter]}${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used " + if [[ $( wc -c <<< ${a_partition_data[$counter]} ) -gt $line_max ]];then + ((counter++)) + fi fi done - # create the first line - partition_data=$( create_print_line "Partition:" "$partition_data" ) - print_screen_output "$partition_data" - - # then the rest, if required - if [[ -n $partition_data_2 ]];then - partition_data_2=$( create_print_line " " "$partition_data_2" ) - print_screen_output "$partition_data_2" - fi - if [[ -n $partition_data_3 ]];then - partition_data_3=$( create_print_line " " "$partition_data_3" ) - print_screen_output "$partition_data_3" - fi - if [[ -n $partition_data_4 ]];then - partition_data_4=$( create_print_line " " "$partition_data_4" ) - print_screen_output "$partition_data_4" - fi - if [[ -n $partition_data_5 ]];then - partition_data_5=$( create_print_line " " "$partition_data_5" ) - print_screen_output "$partition_data_5" - fi - if [[ -n $partition_data_6 ]];then - partition_data_6=$( create_print_line " " "$partition_data_6" ) - print_screen_output "$partition_data_6" - fi - if [[ -n $partition_data_7 ]];then - partition_data_7=$( create_print_line " " "$partition_data_7" ) - print_screen_output "$partition_data_7" - fi - if [[ -n $partition_data_8 ]];then - partition_data_8=$( create_print_line " " "$partition_data_8" ) - print_screen_output "$partition_data_8" - fi + # print out all lines, line starter on first line + for (( i=0; i < ${#a_partition_data[@]};i++ )) + do + if [[ $i -eq 0 ]];then + line_starter='Partition:' + else + line_starter=' ' + fi + partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" ) + print_screen_output "$partition_data" + done } print_system_data()