New version. Updated dynamic sizing, fixed some glitches in cpu flags, fixed bugs in

cpu main. Cleaned up a few more variable and width issues. Used a few more ${#var} for
counting.
This commit is contained in:
inxi-svn 2014-03-15 03:41:16 +00:00
parent e8e3f9be84
commit 0c7d9ebc10
2 changed files with 53 additions and 31 deletions

70
inxi
View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 2.1.1
#### Version: 2.1.2
#### Date: 2014-03-14
#### Patch Number: 00
########################################################################
@ -672,8 +672,8 @@ main()
fi
COLS_MAX=$COLS_MAX_IRC
fi
COLS_INNER=$(( $COLS_MAX - $INDENT - 4 ))
COLS_INNER=$(( $COLS_MAX - $INDENT - 1 ))
# Check for dependencies BEFORE running ANYTHING else except above functions
# Not all distro's have these depends installed by default. Don't want to run
# this if the user is requesting to see this information in the first place
@ -2010,7 +2010,8 @@ print_screen_output()
{
eval $LOGFS
# the double quotes are needed to avoid losing whitespace in data when certain output types are used
local print_data="$( echo -e "$1" )"
# trim off whitespace at end
local print_data="$( echo -e "$1" )"
# just using basic debugger stuff so you can tell which thing is printing out the data. This
# should help debug kde 4 konvi issues when that is released into sid, we'll see. Turning off
@ -2053,7 +2054,8 @@ print_screen_output()
create_print_line()
{
eval $LOGFS
printf "${C1}%-${INDENT}s${C2} %s" "$1" "$2"
local line=$2
printf "${C1}%-${INDENT}s${C2} %s" "$1" "$line"
eval $LOGFE
}
@ -8752,7 +8754,7 @@ get_weather_data()
# returns count of string length minus colors
calculate_line_length()
{
local string="$1"
local string=$1
# ansi:  irc: \x0312
string=$( sed -e "s/\x1b\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g" -e "s/\\\x0[0-9]\{1,3\}//g" <<< $string )
count=${#string}
@ -8808,8 +8810,7 @@ process_cpu_flags()
# sse, sse2, pni = sse1,2,3,4,5 gfx extensions
# svm = AMD pacifica virtualization extensions
# vmx = Intel IVT (vanderpool) virtualization extensions
cpu_flags=$(
echo "$cpu_flags_working" | gawk '
cpu_flags=$( gawk '
BEGIN {
RS=" "
count = 0
@ -8838,7 +8839,7 @@ process_cpu_flags()
}
}
print flag_string
}' )
}' <<< "$cpu_flags_working" )
#grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))
if [[ -z $cpu_flags ]];then
@ -9176,7 +9177,7 @@ print_cpu_data()
local a_cpu_working='' cpu_model='' cpu_clock='' cpu_null_error=''
local cpc_plural='' cpu_count_print='' model_plural='' cpu_data_string=''
local cpu_physical_count='' cpu_core_count='' cpu_core_alpha='' cpu_type=''
local cpu_2_data=''
local cpu_2_data='' line_starter=''
##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\""
# Array A_CPU_DATA always has one extra element: max clockfreq found.
@ -9215,9 +9216,9 @@ print_cpu_data()
cpu_count_print="$cpu_physical_count "
model_plural='s'
fi
line_starter="CPU$cpc_plural:"
cpu_data_string="${cpu_count_print}${cpu_core_alpha} core"
cpu_data=$( create_print_line "CPU$cpc_plural:" "${C1}${cpu_data_string}${C2} ${a_cpu_working[0]}$model_plural (${cpu_type})" )
cpu_data="${C1}${cpu_data_string}${C2} ${a_cpu_working[0]}$model_plural (${cpu_type})"
if [[ $B_SHOW_CPU == 'true' ]];then
# update for multicore, bogomips x core count.
if [[ $B_EXTRA_DATA == 'true' ]];then
@ -9226,6 +9227,7 @@ print_cpu_data()
# echo $cpu_core_count $cpu_physical_count
if [[ -n ${a_cpu_working[4]} ]];then
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
bmip_data=${bmip_data%.*}
fi
# else
# bmip_data="${a_cpu_working[4]}"
@ -9257,6 +9259,7 @@ print_cpu_data()
if [[ ${a_cpu_working[6]} == 'true' ]];then
flag_feature='features'
fi
cpu_flags="${C1}$flag_feature$SEP3${C2} $cpu_flags "
fi
fi
@ -9272,25 +9275,30 @@ print_cpu_data()
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
cpu_clock_speed='' # null < verbosity level 5
else
cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]} MHz${CN}"
cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]%.*} MHz${CN}"
fi
cpu_2_data="$cpu_2_data$cpu_clock_speed"
else
if [[ $BSD_TYPE == 'bsd' && $B_ROOT != 'true' ]];then
cpu_null_error=' No permissions for sysctl use?'
fi
cpu_data=$( create_print_line "CPU:" "${C2}No CPU data available.$cpu_null_error" )
cpu_data="${C2}No CPU data available.$cpu_null_error"
fi
# echo ln: $( calculate_line_length "$cpu_data $cpu_2_data" )
# echo icols: $COLS_INNER
# echo tc: $TERM_COLUMNS
# echo :$cpu_2_data:
# echo $cpu_data $cpu_2_data
# echo ln: $( calculate_line_length "$cpu_data $cpu_2_data" )
# echo cpl: $( create_print_line "$line_starter" "${cpu_2_data}" ):
# echo icols: $COLS_INNER
# echo tc: $TERM_COLUMNS
# echo :${cpu_2_data}:
if [[ -n $cpu_2_data && $( calculate_line_length "$cpu_data $cpu_2_data" ) -gt $COLS_INNER ]];then
cpu_data=$( create_print_line "$line_starter" "${cpu_data}" )
line_starter=''
print_screen_output "$cpu_data"
cpu_data=$( create_print_line " " "$cpu_2_data" )
cpu_data=$( create_print_line " " "${cpu_2_data}" )
print_screen_output "$cpu_data"
else
print_screen_output "$cpu_data $cpu_2_data"
cpu_data=$( create_print_line "$line_starter" "${cpu_data}" )
print_screen_output "$cpu_data ${cpu_2_data}"
fi
# we don't this printing out extra line unless > 1 cpu core
# note the numbering, the last array item is the min/max/not found for cpu speeds
@ -9301,7 +9309,7 @@ print_cpu_data()
a_cpu_working=(${A_CPU_DATA[i]})
IFS="$ORIGINAL_IFS"
# note: the first iteration will create a first space, for color code separation below
cpu_multi_clock_data="$cpu_multi_clock_data ${C1}$(( i + 1 )):${C2} ${a_cpu_working[1]} MHz${CN}"
cpu_multi_clock_data="$cpu_multi_clock_data ${C1}$(( i + 1 )):${C2} ${a_cpu_working[1]%.*} MHz${CN}"
# someone actually appeared with a 16 core system, so going to stop the cpu core throttle
# if this had some other purpose which we can't remember we'll add it back in
#if [[ $i -gt 10 ]];then
@ -9333,24 +9341,26 @@ print_cpu_flags_full()
if [[ $2 == 'true' ]];then
flag_feature='Features'
fi
line_starter="CPU $flag_feature$SEP3"
starter_length=$(( ${#line_starter} + 1 ))
line_starter="${C1}$line_starter${C2} "
line_length=$(( $COLS_INNER - $starter_length ))
# build the flag line array
for flag in $cpu_flags_full
do
temp_string="$flag_string$spacer$flag"
spacer=' '
# handle inner line starter
if [[ $counter -eq 0 ]];then
line_length=$(( $COLS_INNER - $starter_length ))
else
if [[ $counter -gt 0 ]];then
line_length=$COLS_INNER
fi
if [[ ${#temp_string} -gt $line_length ]];then
a_cpu_flags[$counter]=$temp_string
if [[ $line_length -ge ${#temp_string} ]];then
flag_string=$temp_string
else
a_cpu_flags[$counter]=$flag_string
flag_string=''
spacer=''
(( counter++ ))
else
flag_string=$temp_string
fi
temp_string=''
done
@ -9360,9 +9370,7 @@ print_cpu_flags_full()
# then print it out
for (( i=0; i < ${#a_cpu_flags[@]};i++ ))
do
if [[ $i -eq 0 ]];then
line_starter="${C1}CPU $flag_feature$SEP3${C2} "
else
if [[ $i -gt 0 ]];then
line_starter=''
fi
flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" )

View file

@ -1,3 +1,17 @@
=====================================================================================
Version: 2.1.2
Patch Version: 00
Script Date: 2014-03-14
-----------------------------------
Changes:
-----------------------------------
New version. Updated dynamic sizing, fixed some glitches in cpu flags, fixed bugs in
cpu main. Cleaned up a few more variable and width issues. Used a few more ${#var} for
counting.
-----------------------------------
-- Harald Hope - Fri, 14 Mar 2014 20:39:13 -0700
=====================================================================================
Version: 2.1.1
Patch Version: 00