diff --git a/inxi b/inxi index 74a738e..fb8ed64 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.9.3 -#### Date: January 6, 2009 +#### version: 0.9.4 +#### Date: January 8, 2009 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -1862,25 +1862,28 @@ get_hdd_data_basic() local hdd_used='' hdd_used=$( df | gawk ' - p { - if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) { - if (NF == 1) { - getline - if (NF == 5) { - c += $2 - } - else { - next - } - } - else if (NF == 6) { - c += $3 - } + /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ { + # this handles the case where the first item is too long + # and makes df wrap output to next line, so here we advance + # it to the next line for that single case + if ( NF == 1 ) { + getline + } + # if the first item caused a wrap, use one less than standard + if ( $4 ~ /.*\%/ ) { + used += $2 + } + # otherwise use standard + else if ( $5 ~ /.*\%/ ) { + used += $3 + } + # and if this is not detected, give up, we need user data to debug + else { + next } } - /^Filesystem/ { p++ } END { - print c + print used }' ) if [[ -z $hdd_used ]];then @@ -1903,7 +1906,9 @@ get_hdd_data_basic() # See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below # $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} # special case from this data: 8 0 156290904 sda - $1 ~ /^(3|22|33|8)$/ && $NF ~ /[hs]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) {size+=$3} + $1 ~ /^(3|22|33|8)$/ && $NF ~ /[hs]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { + size += $3 + } END { size = size*1024/1000**3 # calculate size in GB size workingUsed = hddused*1024/1000**3 # calculate workingUsed in GB used