mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
refactored into primary data get and print functions
This commit is contained in:
parent
862eb60967
commit
af2a1da5db
421
inxi
421
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.1.11
|
#### version: 0.1.20
|
||||||
#### Date: October 27 2008
|
#### Date: October 27 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||||
|
@ -563,22 +563,20 @@ set_konvi()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# temp function to contain all script core engine pieces until they are broken into real functions
|
get_distro_data()
|
||||||
main_temp_engine()
|
|
||||||
{
|
{
|
||||||
|
unset DISTRO
|
||||||
|
shopt -s nullglob
|
||||||
|
cd /etc
|
||||||
|
DISTGLOB=(*[-_]{release,version})
|
||||||
|
cd "$OLDPWD"
|
||||||
|
shopt -u nullglob
|
||||||
|
|
||||||
unset DISTRO
|
if (( ${#DISTGLOB[@]} == 1 ))
|
||||||
shopt -s nullglob
|
then
|
||||||
cd /etc
|
|
||||||
DISTGLOB=(*[-_]{release,version})
|
|
||||||
cd "$OLDPWD"
|
|
||||||
shopt -u nullglob
|
|
||||||
|
|
||||||
if (( ${#DISTGLOB[@]} == 1 ))
|
|
||||||
then
|
|
||||||
DISTFILE="${DISTGLOB}"
|
DISTFILE="${DISTGLOB}"
|
||||||
elif (( ${#DISTGLOB[@]} > 1 ))
|
elif (( ${#DISTGLOB[@]} > 1 ))
|
||||||
then
|
then
|
||||||
for I in $DISTROS_SECONDARY $DISTROS_PRIMARY
|
for I in $DISTROS_SECONDARY $DISTROS_PRIMARY
|
||||||
do
|
do
|
||||||
# Only echo works with ${var[@]}, not print_screen_output() or script_debugger()
|
# Only echo works with ${var[@]}, not print_screen_output() or script_debugger()
|
||||||
|
@ -590,29 +588,32 @@ then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ -n "$DISTFILE" -a -s /etc/$DISTFILE -a " $DISTROS_BLIST " != *" $DISTFILE "* ]
|
if [ -n "$DISTFILE" -a -s /etc/$DISTFILE -a " $DISTROS_BLIST " != *" $DISTFILE "* ]
|
||||||
then
|
then
|
||||||
DISTRO=$( eat "/etc/$DISTFILE" )
|
DISTRO=$( eat "/etc/$DISTFILE" )
|
||||||
else
|
else
|
||||||
# Debian pure should fall through here
|
# Debian pure should fall through here
|
||||||
DISTFILE="issue"
|
DISTFILE="issue"
|
||||||
DISTRO=$( gawk 'BEGIN { RS="" } { gsub(/\\[a-z]/,""); gsub(/ [ ]+/," "); gsub(/^ +| +$/,""); print }' "/etc/${DISTFILE}" )
|
DISTRO=$( gawk 'BEGIN { RS="" } { gsub(/\\[a-z]/,""); gsub(/ [ ]+/," "); gsub(/^ +| +$/,""); print }' "/etc/${DISTFILE}" )
|
||||||
fi
|
fi
|
||||||
((${#DISTRO} > 80 && ! CRAP)) && DISTRO="${RED}/etc/${DISTFILE} corrupted, use --crap to override${NORMAL}"
|
((${#DISTRO} > 80 && ! CRAP)) && DISTRO="${RED}/etc/${DISTFILE} corrupted, use --crap to override${NORMAL}"
|
||||||
: ${DISTRO:=Unknown distro o_O}
|
: ${DISTRO:=Unknown distro o_O}
|
||||||
|
}
|
||||||
|
|
||||||
OSKERN=$( uname -a | gawk '{print $1,$3,$(NF-1)}' )
|
get_cpu_data()
|
||||||
|
{
|
||||||
|
OSKERN=$( uname -a | gawk '{print $1,$3,$(NF-1)}' )
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
CPU=($(gawk -F': ' '
|
CPU=($(gawk -F': ' '
|
||||||
# TAKE NOTE: \t+ will work for /proc/cpuinfo, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
|
# TAKE NOTE: \t+ will work for /proc/cpuinfo, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
|
||||||
# Therefore PATCH to use [ \t]+ when TESTING!
|
# Therefore PATCH to use [ \t]+ when TESTING!
|
||||||
/^processor\t+:/ { nr = $NF }
|
/^processor\t+:/ { nr = $NF }
|
||||||
|
|
||||||
/^model name/ { cpu[nr, "model"] = $NF }
|
/^model name/ { cpu[nr, "model"] = $NF }
|
||||||
|
|
||||||
/^cpu MHz/ {
|
/^cpu MHz/ {
|
||||||
if (!min) {
|
if (!min) {
|
||||||
min = $NF
|
min = $NF
|
||||||
}
|
}
|
||||||
|
@ -622,15 +623,15 @@ CPU=($(gawk -F': ' '
|
||||||
|
|
||||||
if ($NF > max) { max = $NF }
|
if ($NF > max) { max = $NF }
|
||||||
cpu[nr, "speed"] = $NF
|
cpu[nr, "speed"] = $NF
|
||||||
}
|
}
|
||||||
|
|
||||||
/^cache size/ { cpu[nr, "cache"] = $NF }
|
/^cache size/ { cpu[nr, "cache"] = $NF }
|
||||||
|
|
||||||
/^flags/ { cpu[nr, "flags"] = $NF }
|
/^flags/ { cpu[nr, "flags"] = $NF }
|
||||||
|
|
||||||
/^bogomips/ { cpu[nr, "bogomips"] = $NF }
|
/^bogomips/ { cpu[nr, "bogomips"] = $NF }
|
||||||
|
|
||||||
END {
|
END {
|
||||||
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
|
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
|
||||||
for (i = 0; i <= nr; i++) {
|
for (i = 0; i <= nr; i++) {
|
||||||
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"]
|
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"]
|
||||||
|
@ -645,12 +646,12 @@ END {
|
||||||
else {
|
else {
|
||||||
printf("%s %s\n", max, "Mhz")
|
printf("%s %s\n", max, "Mhz")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' /proc/cpuinfo))
|
' /proc/cpuinfo))
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
|
|
||||||
for (( I=0; I < ${#CPU[@]} - 1; I++))
|
for (( I=0; I < ${#CPU[@]} - 1; I++))
|
||||||
do
|
do
|
||||||
IFS=","; CPUTMP=(${CPU[I]}); IFS="$OIFS"
|
IFS=","; CPUTMP=(${CPU[I]}); IFS="$OIFS"
|
||||||
unset CPU[I]
|
unset CPU[I]
|
||||||
CPUTMP[0]=$( sanitize NORMAL_BANS "${CPUTMP[0]}" )
|
CPUTMP[0]=$( sanitize NORMAL_BANS "${CPUTMP[0]}" )
|
||||||
|
@ -665,12 +666,12 @@ do
|
||||||
CPU[I]="${CPUTMP[J]}"
|
CPU[I]="${CPUTMP[J]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if echo "${CPU[@]}" | grep -qi 'dual\|triple\|quad'
|
if echo "${CPU[@]}" | grep -qi 'dual\|triple\|quad'
|
||||||
then
|
then
|
||||||
NO_CPU_COUNT=1
|
NO_CPU_COUNT=1
|
||||||
else
|
else
|
||||||
case $(( ${#CPU[@]}-1 )) in
|
case $(( ${#CPU[@]}-1 )) in
|
||||||
2)
|
2)
|
||||||
CPU2="Dual"
|
CPU2="Dual"
|
||||||
|
@ -688,22 +689,22 @@ else
|
||||||
unset CPU2
|
unset CPU2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=","
|
IFS=","
|
||||||
CPUTMP=(${CPU[0]})
|
CPUTMP=(${CPU[0]})
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
# For the short line
|
# For the short line
|
||||||
CPUMODEL="${CPU2}${CPU2+ }${CPUTMP[0]}" # clocked at [${CPU[${#CPU[@]}-1]}]" # old CPU2
|
CPUMODEL="${CPU2}${CPU2+ }${CPUTMP[0]}" # clocked at [${CPU[${#CPU[@]}-1]}]" # old CPU2
|
||||||
CPUCLOCK="$CPU[${#CPU[@]}-1]" # old CPU3
|
CPUCLOCK="$CPU[${#CPU[@]}-1]" # old CPU3
|
||||||
CPUFLAGS="${CPUTMP[3]}" # old CPU4
|
CPUFLAGS="${CPUTMP[3]}" # old CPU4
|
||||||
# nx = AMD stack protection extensions
|
# nx = AMD stack protection extensions
|
||||||
# lm = Intel 64bit extensions
|
# lm = Intel 64bit extensions
|
||||||
# sse, sse2, pni = sse1,2,3 gfx extensions
|
# sse, sse2, pni = sse1,2,3 gfx extensions
|
||||||
# svm = AMD pacifica virtualization extensions
|
# svm = AMD pacifica virtualization extensions
|
||||||
# vmx = Intel IVT (vanderpool) virtualization extensions
|
# vmx = Intel IVT (vanderpool) virtualization extensions
|
||||||
CPUFLAGS=$(echo "$CPUFLAGS" | awk '
|
CPUFLAGS=$(echo "$CPUFLAGS" | awk '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
RS=" "
|
RS=" "
|
||||||
ssel["sse"] = 1
|
ssel["sse"] = 1
|
||||||
ssel["sse2"] = 2
|
ssel["sse2"] = 2
|
||||||
|
@ -711,31 +712,34 @@ BEGIN {
|
||||||
sses[1] = "sse"
|
sses[1] = "sse"
|
||||||
sses[2] = "sse2"
|
sses[2] = "sse2"
|
||||||
sses[3] = "sse3"
|
sses[3] = "sse3"
|
||||||
}
|
}
|
||||||
/^(nx|lm|svm|vmx)$/ {
|
/^(nx|lm|svm|vmx)$/ {
|
||||||
if (s) { s = s " " $0 }
|
if (s) { s = s " " $0 }
|
||||||
else { s = $0 }
|
else { s = $0 }
|
||||||
}
|
}
|
||||||
/^(sse2?|pni)$/ {
|
/^(sse2?|pni)$/ {
|
||||||
if (ssel[$0] > sse) sse = ssel[$0]
|
if (ssel[$0] > sse) sse = ssel[$0]
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
if (sse) {
|
if (sse) {
|
||||||
if (s) s = sses[sse] " " s;
|
if (s) s = sses[sse] " " s;
|
||||||
else s = sses[sse]
|
else s = sses[sse]
|
||||||
}
|
}
|
||||||
print s
|
print s
|
||||||
}
|
}
|
||||||
')
|
')
|
||||||
|
|
||||||
#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 $CPUFLAGS ]]
|
if [[ -z $CPUFLAGS ]]
|
||||||
then
|
then
|
||||||
CPUFLAGS="-"
|
CPUFLAGS="-"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
for I in /proc/ide/ide*/hd*
|
get_hard_drive_data()
|
||||||
do
|
{
|
||||||
|
for I in /proc/ide/ide*/hd*
|
||||||
|
do
|
||||||
if [[ -e $I/media && $(eat $I/media) = disk ]]
|
if [[ -e $I/media && $(eat $I/media) = disk ]]
|
||||||
then
|
then
|
||||||
# BUGFIX: Ran into a debian sarge kernel that did not have the "capacity" file in the hd* directories
|
# BUGFIX: Ran into a debian sarge kernel that did not have the "capacity" file in the hd* directories
|
||||||
|
@ -747,10 +751,10 @@ do
|
||||||
(( CAP+=$( eat $I/capacity ) ))
|
(( CAP+=$( eat $I/capacity ) ))
|
||||||
HDDMOD="${HDDMOD}${HDDMOD+,}$(eat $I/model)"
|
HDDMOD="${HDDMOD}${HDDMOD+,}$(eat $I/model)"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -e /proc/scsi/scsi ]]
|
if [[ -e /proc/scsi/scsi ]]
|
||||||
then
|
then
|
||||||
# Silly sata detection, will also pick up usb sticks, and it is all I will put into infobash. if you want more, infoperl is on
|
# Silly sata detection, will also pick up usb sticks, and it is all I will put into infobash. if you want more, infoperl is on
|
||||||
# the way :)
|
# the way :)
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
@ -779,27 +783,27 @@ then
|
||||||
do
|
do
|
||||||
HDDMOD="${HDDMOD}${HDDMOD+,}${THDD[I]}"
|
HDDMOD="${HDDMOD}${HDDMOD+,}${THDD[I]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##print_screen_output "$HDDMOD" ; exit
|
##print_screen_output "$HDDMOD" ; exit
|
||||||
if ((CAP))
|
if ((CAP))
|
||||||
then
|
then
|
||||||
HDDCAP1="$((CAP/2))"
|
HDDCAP1="$((CAP/2))"
|
||||||
fi
|
fi
|
||||||
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
|
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
|
||||||
HDDCAP2=$( gawk '$1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} END {printf("%d\n",size)}' /proc/partitions )
|
HDDCAP2=$( gawk '$1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} END {printf("%d\n",size)}' /proc/partitions )
|
||||||
|
|
||||||
##print_screen_output "HDDCAP1=\"$HDDCAP1\" HDDCAP2=\"$HDDCAP2"" ; exit
|
##print_screen_output "HDDCAP1=\"$HDDCAP1\" HDDCAP2=\"$HDDCAP2"" ; exit
|
||||||
HDD=0
|
HDD=0
|
||||||
for I in ${!HDDCAP*}
|
for I in ${!HDDCAP*}
|
||||||
do
|
do
|
||||||
if [[ ${!I} -gt $HDD ]]
|
if [[ ${!I} -gt $HDD ]]
|
||||||
then
|
then
|
||||||
HDD="${!I}"
|
HDD="${!I}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if ((HDD))
|
if ((HDD))
|
||||||
then
|
then
|
||||||
HDDUSG=$( df | gawk '
|
HDDUSG=$( df | gawk '
|
||||||
p {
|
p {
|
||||||
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
|
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
|
||||||
|
@ -816,34 +820,43 @@ then
|
||||||
' )
|
' )
|
||||||
HDDUSG="$((HDDUSG*100/HDD))%used"
|
HDDUSG="$((HDDUSG*100/HDD))%used"
|
||||||
HDD="$(($HDD*1024/1000**3))GB"
|
HDD="$(($HDD*1024/1000**3))GB"
|
||||||
else
|
else
|
||||||
unset HDDUSG
|
unset HDDUSG
|
||||||
HDD="unknown.."
|
HDD="unknown.."
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
MEM=$( gawk '
|
get_memory_data()
|
||||||
/^MemTotal:/ { tot = $2 }
|
{
|
||||||
/^(MemFree|Buffers|Cached):/ { notused+=$2 }
|
MEM=$( gawk '
|
||||||
END {
|
/^MemTotal:/ { tot = $2 }
|
||||||
|
/^(MemFree|Buffers|Cached):/ { notused+=$2 }
|
||||||
|
END {
|
||||||
used = tot-notused
|
used = tot-notused
|
||||||
printf("%.1f/%.1fMB\n", used/1024, tot/1024)
|
printf("%.1f/%.1fMB\n", used/1024, tot/1024)
|
||||||
}' /proc/meminfo )
|
}' /proc/meminfo )
|
||||||
|
}
|
||||||
|
|
||||||
PROC="$(( $( ps aux | wc -l ) - 1 ))"
|
get_processes_uptime()
|
||||||
UPT=$( uptime | gawk '{ a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0); gsub(/ /,"",a); print a }' )
|
{
|
||||||
|
PROC="$(( $( ps aux | wc -l ) - 1 ))"
|
||||||
|
UPT=$( uptime | gawk '{ a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0); gsub(/ /,"",a); print a }' )
|
||||||
|
}
|
||||||
|
|
||||||
IFS=$'\n'
|
get_graphics_data()
|
||||||
GFX=($( echo "$LSPCI" | gawk -F': ' '/VGA compatible controller/ { print $NF }' ))
|
{
|
||||||
IFS="$OIFS"
|
IFS=$'\n'
|
||||||
for (( I=0; I < ${#GFX[@]}; I++ ))
|
GFX=($( echo "$LSPCI" | gawk -F': ' '/VGA compatible controller/ { print $NF }' ))
|
||||||
do
|
IFS="$OIFS"
|
||||||
|
for (( I=0; I < ${#GFX[@]}; I++ ))
|
||||||
|
do
|
||||||
GFX[I]=$( sanitize NORMAL_BANS "${GFX[I]}" )
|
GFX[I]=$( sanitize NORMAL_BANS "${GFX[I]}" )
|
||||||
done
|
done
|
||||||
|
|
||||||
# GFXMEM is UNUSED at the moment, because it shows AGP aperture size, which is not necessarily equal to GFX memory..
|
# GFXMEM is UNUSED at the moment, because it shows AGP aperture size, which is not necessarily equal to GFX memory..
|
||||||
# GFXMEM="size=[$(echo "$LSPCI" | gawk '/VGA/{while (!/^$/) {getline;if (/size=[0-9][0-9]*M/) {size2=gensub(/.*\[size=([0-9]+)M\].*/,"\\1","g",$0);if (size<size2){size=size2}}}}END{print size2}')M]"
|
# GFXMEM="size=[$(echo "$LSPCI" | gawk '/VGA/{while (!/^$/) {getline;if (/size=[0-9][0-9]*M/) {size2=gensub(/.*\[size=([0-9]+)M\].*/,"\\1","g",$0);if (size<size2){size=size2}}}}END{print size2}')M]"
|
||||||
if ((X))
|
if ((X))
|
||||||
then
|
then
|
||||||
# Added the two ?'s , because the resolution is now reported without spaces around the 'x', as in
|
# Added the two ?'s , because the resolution is now reported without spaces around the 'x', as in
|
||||||
# 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0
|
# 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0
|
||||||
RES=$( xrandr | gawk '
|
RES=$( xrandr | gawk '
|
||||||
|
@ -939,91 +952,14 @@ then
|
||||||
MESA=1
|
MESA=1
|
||||||
fi
|
fi
|
||||||
AGPMOD=$(gawk '/agp/ && !/agpgart/ && $3 > 0 { print(gensub(/(.*)_agp.*/,"\\1","g",$1)) }' /proc/modules)
|
AGPMOD=$(gawk '/agp/ && !/agpgart/ && $3 > 0 { print(gensub(/(.*)_agp.*/,"\\1","g",$1)) }' /proc/modules)
|
||||||
else
|
else
|
||||||
RES=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{ print $2"x"$1 }' )
|
RES=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{ print $2"x"$1 }' )
|
||||||
RUNLVL=$( runlevel | gawk '{ print $2 }' )
|
RUNLVL=$( runlevel | gawk '{ print $2 }' )
|
||||||
fi
|
|
||||||
# (IF VERBOSITY_LEVEL > 1)
|
|
||||||
if ((VERBOSITY_LEVEL))
|
|
||||||
then
|
|
||||||
if ((SHOW_HOST))
|
|
||||||
then
|
|
||||||
LNINTRO=$( printf "${C1}%-${INDENT}s${C2} \"%s\"${C1} %s " "Host/Kernel/OS" "$HN" "running" )
|
|
||||||
else
|
|
||||||
LNINTRO=$( printf "${C1}%-${INDENT}s${C2} " "OS/Kernel" )
|
|
||||||
fi
|
fi
|
||||||
LNINTRO="$LNINTRO$( echo -ne "${C2}$OSKERN ${CN}[ ${C1}$DISTRO ${CN}]" )"
|
}
|
||||||
print_screen_output "$LNINTRO"
|
|
||||||
|
|
||||||
##print_screen_output "CPU[0]=\"${CPU[0]}\""
|
get_networking_data()
|
||||||
IFS=","
|
{
|
||||||
CPUTMP=(${CPU[0]})
|
|
||||||
IFS="$OIFS"
|
|
||||||
# Strange (and also some expected) behavior encountered.
|
|
||||||
# If print_screen_output() uses $1 as the parameter to output to the screen, then passing "<text1> ${ARR[@]} <text2>"
|
|
||||||
# will output only <text1> and the first element of ARR. That "@" splits in elements and "*" _doesn't_, is to be expected.
|
|
||||||
# However, that text2 is consecutively truncated is somewhat strange, so take note. This has been confirmed by #bash on freenode.
|
|
||||||
# The above mentioned only emerges when using the debugging markers below
|
|
||||||
##print_screen_output "CPUTMP=\"***${CPUTMP[@]} $HN+++++++\"----------"
|
|
||||||
|
|
||||||
if [[ -z ${CPUTMP[2]} ]]
|
|
||||||
then
|
|
||||||
CPUTMP[2]="unknown"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${#CPU[@]} -gt 2 ]]
|
|
||||||
then
|
|
||||||
CPUNUM="(1)"
|
|
||||||
else
|
|
||||||
# Array CPU always has one element: max clockfreq found. Therefore -gt and not -ge
|
|
||||||
unset CPUNUM
|
|
||||||
fi
|
|
||||||
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" "CPU Info" "${CPUNUM}${CPUNUM+ }${CPUTMP[0]}" )
|
|
||||||
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
|
||||||
then
|
|
||||||
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
|
||||||
fi
|
|
||||||
LNCPU=$( printf "%s ${C1}%s${C2} ${CN}%s${C2} %s ${CN}%s" "$LNCPU" "clocked at" "[" "${CPUTMP[1]} MHz" "]" )
|
|
||||||
print_screen_output "$LNCPU"
|
|
||||||
|
|
||||||
for (( I=1; I < ${#CPU[@]}-1; I++))
|
|
||||||
do
|
|
||||||
IFS=","
|
|
||||||
CPUTMP=(${CPU[I]})
|
|
||||||
IFS="$OIFS"
|
|
||||||
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" " " "($((I+1))) ${CPUTMP[0]}" )
|
|
||||||
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
|
||||||
then
|
|
||||||
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
|
||||||
fi
|
|
||||||
LNCPU=$( printf "%s ${C1}%s${C2} ${CN}%s${C2} %s ${CN}%s" "$LNCPU" "clocked at" "[" "${CPUTMP[1]} MHz" "]" )
|
|
||||||
print_screen_output "$LNCPU"
|
|
||||||
if [[ $I -gt 10 ]]
|
|
||||||
then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
LNGFX=$( printf "${C1}%-${INDENT}s${C2} %s" "Videocard" "${GFX[0]}" )
|
|
||||||
if ((X))
|
|
||||||
then
|
|
||||||
LNGFX="${LNGFX}$( echo -ne "${C1} $XVER ${CN}[${C2} ${RES} ${CN}]" )"
|
|
||||||
else
|
|
||||||
LNGFX="${LNGFX}$( echo -ne "${C1} tty resolution ${CN}(${C2} ${RES} ${CN})" )"
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_screen_output "$LNGFX"
|
|
||||||
I=1
|
|
||||||
while [[ -n ${GFX[I]} && $I -le 3 ]]
|
|
||||||
do
|
|
||||||
LNGFX=$( printf "${C1}%-${INDENT}s${C2} %s" " " "${GFX[I]}" )
|
|
||||||
print_screen_output "$LNGFX"
|
|
||||||
(( I++ ))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $VERBOSITY_LEVEL -ge 2 ]]
|
|
||||||
then
|
|
||||||
IFS=$'\n' LNNET=($( echo "$LSPCI" | gawk '
|
IFS=$'\n' LNNET=($( echo "$LSPCI" | gawk '
|
||||||
BEGIN { IGNORECASE=1 }
|
BEGIN { IGNORECASE=1 }
|
||||||
/^[0-9a-f:.]+ (ethernet|network) (controller|bridge)/ || /^[0-9a-f:.]+ [^:]+: .*(ethernet|network).*$/ {
|
/^[0-9a-f:.]+ (ethernet|network) (controller|bridge)/ || /^[0-9a-f:.]+ [^:]+: .*(ethernet|network).*$/ {
|
||||||
|
@ -1070,6 +1006,94 @@ then
|
||||||
print_screen_output "$( printf "${C1}%-${INDENT}s${C2} %s" " " "${LNNET[I]}" )"
|
print_screen_output "$( printf "${C1}%-${INDENT}s${C2} %s" " " "${LNNET[I]}" )"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
print_it_out()
|
||||||
|
{
|
||||||
|
# (IF VERBOSITY_LEVEL > 1)
|
||||||
|
if ((VERBOSITY_LEVEL))
|
||||||
|
then
|
||||||
|
if ((SHOW_HOST))
|
||||||
|
then
|
||||||
|
LNINTRO=$( printf "${C1}%-${INDENT}s${C2} \"%s\"${C1} %s " "Host/Kernel/OS" "$HN" "running" )
|
||||||
|
else
|
||||||
|
LNINTRO=$( printf "${C1}%-${INDENT}s${C2} " "OS/Kernel" )
|
||||||
|
fi
|
||||||
|
LNINTRO="$LNINTRO$( echo -ne "${C2}$OSKERN ${CN}[ ${C1}$DISTRO ${CN}]" )"
|
||||||
|
print_screen_output "$LNINTRO"
|
||||||
|
|
||||||
|
##print_screen_output "CPU[0]=\"${CPU[0]}\""
|
||||||
|
IFS=","
|
||||||
|
CPUTMP=(${CPU[0]})
|
||||||
|
IFS="$OIFS"
|
||||||
|
# Strange (and also some expected) behavior encountered.
|
||||||
|
# If print_screen_output() uses $1 as the parameter to output to the screen,
|
||||||
|
# then passing "<text1> ${ARR[@]} <text2>"
|
||||||
|
# will output only <text1> and the first element of ARR. That "@" splits in elements and "*" _doesn't_,
|
||||||
|
# is to be expected.
|
||||||
|
# However, that text2 is consecutively truncated is somewhat strange, so take note.
|
||||||
|
# This has been confirmed by #bash on freenode.
|
||||||
|
# The above mentioned only emerges when using the debugging markers below
|
||||||
|
##print_screen_output "CPUTMP=\"***${CPUTMP[@]} $HN+++++++\"----------"
|
||||||
|
|
||||||
|
if [[ -z ${CPUTMP[2]} ]]
|
||||||
|
then
|
||||||
|
CPUTMP[2]="unknown"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${#CPU[@]} -gt 2 ]]
|
||||||
|
then
|
||||||
|
CPUNUM="(1)"
|
||||||
|
else
|
||||||
|
# Array CPU always has one element: max clockfreq found. Therefore -gt and not -ge
|
||||||
|
unset CPUNUM
|
||||||
|
fi
|
||||||
|
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" "CPU Info" "${CPUNUM}${CPUNUM+ }${CPUTMP[0]}" )
|
||||||
|
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
||||||
|
then
|
||||||
|
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||||
|
fi
|
||||||
|
LNCPU=$( printf "%s ${C1}%s${C2} ${CN}%s${C2} %s ${CN}%s" "$LNCPU" "clocked at" "[" "${CPUTMP[1]} MHz" "]" )
|
||||||
|
print_screen_output "$LNCPU"
|
||||||
|
|
||||||
|
for (( I=1; I < ${#CPU[@]}-1; I++))
|
||||||
|
do
|
||||||
|
IFS=","
|
||||||
|
CPUTMP=(${CPU[I]})
|
||||||
|
IFS="$OIFS"
|
||||||
|
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" " " "($((I+1))) ${CPUTMP[0]}" )
|
||||||
|
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
||||||
|
then
|
||||||
|
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||||
|
fi
|
||||||
|
LNCPU=$( printf "%s ${C1}%s${C2} ${CN}%s${C2} %s ${CN}%s" "$LNCPU" "clocked at" "[" "${CPUTMP[1]} MHz" "]" )
|
||||||
|
print_screen_output "$LNCPU"
|
||||||
|
if [[ $I -gt 10 ]]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
LNGFX=$( printf "${C1}%-${INDENT}s${C2} %s" "Videocard" "${GFX[0]}" )
|
||||||
|
if ((X))
|
||||||
|
then
|
||||||
|
LNGFX="${LNGFX}$( echo -ne "${C1} $XVER ${CN}[${C2} ${RES} ${CN}]" )"
|
||||||
|
else
|
||||||
|
LNGFX="${LNGFX}$( echo -ne "${C1} tty resolution ${CN}(${C2} ${RES} ${CN})" )"
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_screen_output "$LNGFX"
|
||||||
|
I=1
|
||||||
|
while [[ -n ${GFX[I]} && $I -le 3 ]]
|
||||||
|
do
|
||||||
|
LNGFX=$( printf "${C1}%-${INDENT}s${C2} %s" " " "${GFX[I]}" )
|
||||||
|
print_screen_output "$LNGFX"
|
||||||
|
(( I++ ))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $VERBOSITY_LEVEL -ge 2 ]]
|
||||||
|
then
|
||||||
|
get_networking_data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch!
|
# Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch!
|
||||||
|
@ -1105,7 +1129,7 @@ then
|
||||||
LNLAST="${LNLAST}$( echo -ne "${NORMAL}" )"
|
LNLAST="${LNLAST}$( echo -ne "${NORMAL}" )"
|
||||||
fi
|
fi
|
||||||
print_screen_output "$LNLAST"
|
print_screen_output "$LNLAST"
|
||||||
else # (IF VERBOSITY_LEVEL > 1 ... ELSE)
|
else # (IF VERBOSITY_LEVEL > 1 ... ELSE)
|
||||||
#set_color_scheme 12
|
#set_color_scheme 12
|
||||||
if ! ((IBSHELL))
|
if ! ((IBSHELL))
|
||||||
then
|
then
|
||||||
|
@ -1141,12 +1165,9 @@ else # (IF VERBOSITY_LEVEL > 1 ... ELSE)
|
||||||
LNSHORT="${LNSHORT}$( echo -ne "$NORMAL" )"
|
LNSHORT="${LNSHORT}$( echo -ne "$NORMAL" )"
|
||||||
fi
|
fi
|
||||||
print_screen_output "$LNSHORT"
|
print_screen_output "$LNSHORT"
|
||||||
fi # (IF VERBOSITY_LEVEL > 1)
|
fi # (IF VERBOSITY_LEVEL > 1)
|
||||||
|
|
||||||
## end main_temp_engine
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#### SCRIPT EXECUTION
|
#### SCRIPT EXECUTION
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -1171,8 +1192,16 @@ set_konvi
|
||||||
|
|
||||||
script_debugger "ALLUP=1 : inxi up and running.."
|
script_debugger "ALLUP=1 : inxi up and running.."
|
||||||
|
|
||||||
# we'll pull these features out one by one and make them into real functions
|
# assemble data for output
|
||||||
main_temp_engine
|
get_distro_data
|
||||||
|
get_cpu_data
|
||||||
|
get_hard_drive_data
|
||||||
|
get_memory_data
|
||||||
|
get_processes_uptime
|
||||||
|
get_graphics_data
|
||||||
|
|
||||||
|
# then create the output
|
||||||
|
print_it_out
|
||||||
|
|
||||||
## last steps
|
## last steps
|
||||||
if ((IBSHELL && SCHEME))
|
if ((IBSHELL && SCHEME))
|
||||||
|
|
Loading…
Reference in a new issue