mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 08:57:57 +00:00
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:
parent
e8e3f9be84
commit
0c7d9ebc10
66
inxi
66
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### Version: 2.1.1
|
#### Version: 2.1.2
|
||||||
#### Date: 2014-03-14
|
#### Date: 2014-03-14
|
||||||
#### Patch Number: 00
|
#### Patch Number: 00
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -672,8 +672,8 @@ main()
|
||||||
fi
|
fi
|
||||||
COLS_MAX=$COLS_MAX_IRC
|
COLS_MAX=$COLS_MAX_IRC
|
||||||
fi
|
fi
|
||||||
COLS_INNER=$(( $COLS_MAX - $INDENT - 4 ))
|
|
||||||
|
|
||||||
|
COLS_INNER=$(( $COLS_MAX - $INDENT - 1 ))
|
||||||
# Check for dependencies BEFORE running ANYTHING else except above functions
|
# 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
|
# 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
|
# this if the user is requesting to see this information in the first place
|
||||||
|
@ -2010,6 +2010,7 @@ print_screen_output()
|
||||||
{
|
{
|
||||||
eval $LOGFS
|
eval $LOGFS
|
||||||
# the double quotes are needed to avoid losing whitespace in data when certain output types are used
|
# the double quotes are needed to avoid losing whitespace in data when certain output types are used
|
||||||
|
# trim off whitespace at end
|
||||||
local print_data="$( echo -e "$1" )"
|
local print_data="$( echo -e "$1" )"
|
||||||
|
|
||||||
# just using basic debugger stuff so you can tell which thing is printing out the data. This
|
# just using basic debugger stuff so you can tell which thing is printing out the data. This
|
||||||
|
@ -2053,7 +2054,8 @@ print_screen_output()
|
||||||
create_print_line()
|
create_print_line()
|
||||||
{
|
{
|
||||||
eval $LOGFS
|
eval $LOGFS
|
||||||
printf "${C1}%-${INDENT}s${C2} %s" "$1" "$2"
|
local line=$2
|
||||||
|
printf "${C1}%-${INDENT}s${C2} %s" "$1" "$line"
|
||||||
eval $LOGFE
|
eval $LOGFE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8752,7 +8754,7 @@ get_weather_data()
|
||||||
# returns count of string length minus colors
|
# returns count of string length minus colors
|
||||||
calculate_line_length()
|
calculate_line_length()
|
||||||
{
|
{
|
||||||
local string="$1"
|
local string=$1
|
||||||
# ansi: [1;34m irc: \x0312
|
# ansi: [1;34m 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 )
|
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}
|
count=${#string}
|
||||||
|
@ -8808,8 +8810,7 @@ process_cpu_flags()
|
||||||
# sse, sse2, pni = sse1,2,3,4,5 gfx extensions
|
# sse, sse2, pni = sse1,2,3,4,5 gfx extensions
|
||||||
# svm = AMD pacifica virtualization extensions
|
# svm = AMD pacifica virtualization extensions
|
||||||
# vmx = Intel IVT (vanderpool) virtualization extensions
|
# vmx = Intel IVT (vanderpool) virtualization extensions
|
||||||
cpu_flags=$(
|
cpu_flags=$( gawk '
|
||||||
echo "$cpu_flags_working" | gawk '
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
RS=" "
|
RS=" "
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -8838,7 +8839,7 @@ process_cpu_flags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print flag_string
|
print flag_string
|
||||||
}' )
|
}' <<< "$cpu_flags_working" )
|
||||||
|
|
||||||
#grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))
|
#grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))
|
||||||
if [[ -z $cpu_flags ]];then
|
if [[ -z $cpu_flags ]];then
|
||||||
|
@ -9176,7 +9177,7 @@ print_cpu_data()
|
||||||
local a_cpu_working='' cpu_model='' cpu_clock='' cpu_null_error=''
|
local a_cpu_working='' cpu_model='' cpu_clock='' cpu_null_error=''
|
||||||
local cpc_plural='' cpu_count_print='' model_plural='' cpu_data_string=''
|
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_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]}\""
|
##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\""
|
||||||
# Array A_CPU_DATA always has one extra element: max clockfreq found.
|
# 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 "
|
cpu_count_print="$cpu_physical_count "
|
||||||
model_plural='s'
|
model_plural='s'
|
||||||
fi
|
fi
|
||||||
|
line_starter="CPU$cpc_plural:"
|
||||||
cpu_data_string="${cpu_count_print}${cpu_core_alpha} core"
|
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
|
if [[ $B_SHOW_CPU == 'true' ]];then
|
||||||
# update for multicore, bogomips x core count.
|
# update for multicore, bogomips x core count.
|
||||||
if [[ $B_EXTRA_DATA == 'true' ]];then
|
if [[ $B_EXTRA_DATA == 'true' ]];then
|
||||||
|
@ -9226,6 +9227,7 @@ print_cpu_data()
|
||||||
# echo $cpu_core_count $cpu_physical_count
|
# echo $cpu_core_count $cpu_physical_count
|
||||||
if [[ -n ${a_cpu_working[4]} ]];then
|
if [[ -n ${a_cpu_working[4]} ]];then
|
||||||
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
|
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
|
||||||
|
bmip_data=${bmip_data%.*}
|
||||||
fi
|
fi
|
||||||
# else
|
# else
|
||||||
# bmip_data="${a_cpu_working[4]}"
|
# bmip_data="${a_cpu_working[4]}"
|
||||||
|
@ -9257,6 +9259,7 @@ print_cpu_data()
|
||||||
if [[ ${a_cpu_working[6]} == 'true' ]];then
|
if [[ ${a_cpu_working[6]} == 'true' ]];then
|
||||||
flag_feature='features'
|
flag_feature='features'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cpu_flags="${C1}$flag_feature$SEP3${C2} $cpu_flags "
|
cpu_flags="${C1}$flag_feature$SEP3${C2} $cpu_flags "
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -9272,25 +9275,30 @@ print_cpu_data()
|
||||||
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
|
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
|
||||||
cpu_clock_speed='' # null < verbosity level 5
|
cpu_clock_speed='' # null < verbosity level 5
|
||||||
else
|
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
|
fi
|
||||||
cpu_2_data="$cpu_2_data$cpu_clock_speed"
|
cpu_2_data="$cpu_2_data$cpu_clock_speed"
|
||||||
else
|
else
|
||||||
if [[ $BSD_TYPE == 'bsd' && $B_ROOT != 'true' ]];then
|
if [[ $BSD_TYPE == 'bsd' && $B_ROOT != 'true' ]];then
|
||||||
cpu_null_error=' No permissions for sysctl use?'
|
cpu_null_error=' No permissions for sysctl use?'
|
||||||
fi
|
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
|
fi
|
||||||
# echo ln: $( calculate_line_length "$cpu_data $cpu_2_data" )
|
# echo $cpu_data $cpu_2_data
|
||||||
# echo icols: $COLS_INNER
|
# echo ln: $( calculate_line_length "$cpu_data $cpu_2_data" )
|
||||||
# echo tc: $TERM_COLUMNS
|
# echo cpl: $( create_print_line "$line_starter" "${cpu_2_data}" ):
|
||||||
# echo :$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
|
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"
|
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"
|
print_screen_output "$cpu_data"
|
||||||
else
|
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
|
fi
|
||||||
# we don't this printing out extra line unless > 1 cpu core
|
# 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
|
# 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]})
|
a_cpu_working=(${A_CPU_DATA[i]})
|
||||||
IFS="$ORIGINAL_IFS"
|
IFS="$ORIGINAL_IFS"
|
||||||
# note: the first iteration will create a first space, for color code separation below
|
# 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
|
# 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 this had some other purpose which we can't remember we'll add it back in
|
||||||
#if [[ $i -gt 10 ]];then
|
#if [[ $i -gt 10 ]];then
|
||||||
|
@ -9333,24 +9341,26 @@ print_cpu_flags_full()
|
||||||
if [[ $2 == 'true' ]];then
|
if [[ $2 == 'true' ]];then
|
||||||
flag_feature='Features'
|
flag_feature='Features'
|
||||||
fi
|
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
|
# build the flag line array
|
||||||
for flag in $cpu_flags_full
|
for flag in $cpu_flags_full
|
||||||
do
|
do
|
||||||
temp_string="$flag_string$spacer$flag"
|
temp_string="$flag_string$spacer$flag"
|
||||||
spacer=' '
|
spacer=' '
|
||||||
# handle inner line starter
|
# handle inner line starter
|
||||||
if [[ $counter -eq 0 ]];then
|
if [[ $counter -gt 0 ]];then
|
||||||
line_length=$(( $COLS_INNER - $starter_length ))
|
|
||||||
else
|
|
||||||
line_length=$COLS_INNER
|
line_length=$COLS_INNER
|
||||||
fi
|
fi
|
||||||
if [[ ${#temp_string} -gt $line_length ]];then
|
if [[ $line_length -ge ${#temp_string} ]];then
|
||||||
a_cpu_flags[$counter]=$temp_string
|
flag_string=$temp_string
|
||||||
|
else
|
||||||
|
a_cpu_flags[$counter]=$flag_string
|
||||||
flag_string=''
|
flag_string=''
|
||||||
spacer=''
|
spacer=''
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
else
|
|
||||||
flag_string=$temp_string
|
|
||||||
fi
|
fi
|
||||||
temp_string=''
|
temp_string=''
|
||||||
done
|
done
|
||||||
|
@ -9360,9 +9370,7 @@ print_cpu_flags_full()
|
||||||
# then print it out
|
# then print it out
|
||||||
for (( i=0; i < ${#a_cpu_flags[@]};i++ ))
|
for (( i=0; i < ${#a_cpu_flags[@]};i++ ))
|
||||||
do
|
do
|
||||||
if [[ $i -eq 0 ]];then
|
if [[ $i -gt 0 ]];then
|
||||||
line_starter="${C1}CPU $flag_feature$SEP3${C2} "
|
|
||||||
else
|
|
||||||
line_starter=''
|
line_starter=''
|
||||||
fi
|
fi
|
||||||
flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" )
|
flag_data=$( create_print_line " " "$line_starter${a_cpu_flags[$i]}" )
|
||||||
|
|
|
@ -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
|
Version: 2.1.1
|
||||||
Patch Version: 00
|
Patch Version: 00
|
||||||
|
|
Loading…
Reference in a new issue