mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
Tweaked output, fixed bugs, mostly done with major refactoring now
This commit is contained in:
parent
24d855bd93
commit
d7f6f92245
51
inxi
51
inxi
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 0.1.36
|
||||
#### version: 0.1.37
|
||||
#### Date: October 29 2008
|
||||
########################################################################
|
||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||
|
@ -60,9 +60,10 @@ DEBUG_FLOOD=0 # Debug flood override: toggle on to allow long debug output
|
|||
DEFAULT_SCHEME=2 # Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Set to any other valid scheme you like. Same as runtime parameter.
|
||||
FLAG=0 # A throw-away 'flag' variable intended to be used throughout infobash
|
||||
IBSHELL=0 # Running in a shell? Defaults to false, and is determined later.
|
||||
INDENT=14 # Default indentation level
|
||||
INDENT=10 # Default indentation level
|
||||
KONVI=0 # default to false, no konversation found
|
||||
LSPCI=$( lspci -v | awk '{ gsub(/\(prog-if[^)]*\)/,""); print }' )
|
||||
MESA=0
|
||||
NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
|
||||
PARAMETER_LIMIT=30 # This is a variable that controls how many parameters infobash will parse in a /proc/<pid>/cmdline file before stopping.
|
||||
RUNLVL=0 # just setting this to 0 to initialize and avoid test errors
|
||||
|
@ -241,6 +242,12 @@ print_screen_output()
|
|||
# echo -ne "$1\n"
|
||||
}
|
||||
|
||||
## args: $1 - null or line starter; $2 - line content
|
||||
create_print_line()
|
||||
{
|
||||
printf "${C1}%-${INDENT}s${C2} %s" "$1" "$2"
|
||||
}
|
||||
|
||||
# this removes newline and pipes.
|
||||
remove_erroneous_chars()
|
||||
{
|
||||
|
@ -1123,7 +1130,7 @@ get_networking_data()
|
|||
|
||||
print_cpu_data()
|
||||
{
|
||||
local cpu_data='' i='' a_cpu_working=''
|
||||
local cpu_data='' i='' a_cpu_working='' cpu_number=''
|
||||
|
||||
##print_screen_output "CPU[0]=\"${CPU[0]}\""
|
||||
IFS=","
|
||||
|
@ -1146,12 +1153,12 @@ print_cpu_data()
|
|||
|
||||
if [[ ${#A_CPU_DATA[@]} -gt 2 ]]
|
||||
then
|
||||
CPUNUM="${C1}(1)${C2} "
|
||||
cpu_number="${C1}(1)${C2} "
|
||||
else
|
||||
# Array CPU always has one element: max clockfreq found. Therefore -gt and not -ge
|
||||
unset CPUNUM
|
||||
unset cpu_number
|
||||
fi
|
||||
cpu_data=$( printf "${C1}%-${INDENT}s${C2} %s" "CPU Info" "${CPUNUM}${a_cpu_working[0]}" )
|
||||
cpu_data=$( create_print_line "CPU:" "${cpu_number}${a_cpu_working[0]}" )
|
||||
if [ "$VERBOSITY_LEVEL" -ge 3 ]
|
||||
then
|
||||
cpu_data=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$cpu_data" "${a_cpu_working[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||
|
@ -1164,7 +1171,7 @@ print_cpu_data()
|
|||
IFS=","
|
||||
a_cpu_working=(${A_CPU_DATA[i]})
|
||||
IFS="$OIFS"
|
||||
cpu_data=$( printf "${C1}%-${INDENT}s${C2} %s" " " "${C1}($((i+1)))${C2} ${a_cpu_working[0]}" )
|
||||
cpu_data=$( create_print_line " " "${C1}($(( i + 1 )))${C2} ${a_cpu_working[0]}" )
|
||||
if [ "$VERBOSITY_LEVEL" -ge 3 ]
|
||||
then
|
||||
cpu_data=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$cpu_data" "${a_cpu_working[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||
|
@ -1180,18 +1187,19 @@ print_cpu_data()
|
|||
|
||||
print_gfx_data()
|
||||
{
|
||||
local gfx_data='' i=''
|
||||
local gfx_data='' i='' card_one=''
|
||||
|
||||
if [[ ${#A_GFX_DATA[@]} -gt 1 ]]
|
||||
then
|
||||
i=1
|
||||
while [[ -n ${GFX[i]} && $i -le 3 ]]
|
||||
do
|
||||
gfx_data=$( echo -ne " ${C1}Card $(($i+1))${C2} ${GFX[i]} " )
|
||||
gfx_data=$( echo -ne " ${C1}$(($i+1))${C2} ${GFX[i]} " )
|
||||
(( i++ ))
|
||||
done
|
||||
card_one='(1)'
|
||||
fi
|
||||
gfx_data=$( printf "${C1}%-${INDENT}s${C2} %s" "Graphics Info" "${C1}Card 1${C2} ${A_GFX_DATA[0]}${gfx_data}" )
|
||||
gfx_data=$( create_print_line "Graphics:" "${C1}$card_one${C2} ${A_GFX_DATA[0]}${gfx_data}" )
|
||||
if [ "$X" -gt 0 ]
|
||||
then
|
||||
gfx_data="${gfx_data}$( echo -ne "${C1} $XVER ${CN}[${C2} ${RES} ${CN}]" )"
|
||||
|
@ -1202,8 +1210,7 @@ print_gfx_data()
|
|||
|
||||
if [ "$X" -gt 0 -a "$MESA" -eq 0 ]
|
||||
then
|
||||
#long_gfx="$( echo -ne "${INDENT}${C1}GLX Renderer${C2} ${GLXR}${CN} | ${C1}GLX Version${C2} ${GLXV}${CN}" )"
|
||||
gfx_data=$( printf "${C1}%-${INDENT}s${C2} %s" " " "${C1}GLX Renderer${C2} ${GLXR}${CN} | ${C1}GLX Version${C2} ${GLXV}${CN}" )
|
||||
gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${GLXR}${CN} | ${C1}GLX Version${C2} ${GLXV}${CN}" )
|
||||
if ((CRAP))
|
||||
then
|
||||
gfx_data="${gfx_data}$( echo -ne "${C1}Direct rendering${C2} ${GLXDR}${CN}" )"
|
||||
|
@ -1220,9 +1227,9 @@ print_hard_disk_data()
|
|||
|
||||
if [ "$VERBOSITY_LEVEL" -ge 2 ]
|
||||
then
|
||||
hdd_data="$( printf "${C1}%-${INDENT}s${C2} %s" "System Info" "${C1}HDD${C2} ${HDDMOD} ${C1}Size${C2} ${HDD} (${HDDUSG})${CN}" )"
|
||||
hdd_data=$( create_print_line "Disks:" "${C1}HDD${C2} ${HDDMOD} ${C1}Size${C2} ${HDD} (${HDDUSG})${CN}" )
|
||||
else
|
||||
hdd_data="$( printf "${C1}%-${INDENT}s${C2} %s" "System Info" "${C1}HDD Size${C2} ${HDD} (${HDDUSG})${CN}" )"
|
||||
hdd_data=$( create_print_line "Disks:" "${C1}HDD Size${C2} ${HDD} (${HDDUSG})${CN}" )
|
||||
fi
|
||||
print_screen_output "$hdd_data"
|
||||
|
||||
|
@ -1239,17 +1246,17 @@ print_intro_data()
|
|||
|
||||
if [ "$SHOW_HOST" -gt 0 ]
|
||||
then
|
||||
intro_data=$( printf "${C1}%-${INDENT}s${C2} \"%s\"${C1} %s " "Host/Kernel/OS" "$host_name" "running" )
|
||||
intro_data=$( create_print_line "System:" "${C1}Host${C2} $host_name ${C1}running${C2} ${CN}" )
|
||||
else
|
||||
intro_data=$( printf "${C1}%-${INDENT}s${C2} " "OS/Kernel" )
|
||||
intro_data=$( create_print_line "System:" "${C1}running${C2} ${CN}" )
|
||||
fi
|
||||
intro_data="$intro_data$( echo -ne "${C2}$CURRENT_KERNEL ${CN}[ ${C1}$DISTRO ${CN}]" )"
|
||||
intro_data="$intro_data$( echo -ne "${C2}$CURRENT_KERNEL ${C1}Distro${C2} $DISTRO ${CN}" )"
|
||||
print_screen_output "$intro_data"
|
||||
}
|
||||
|
||||
print_networking_data()
|
||||
{
|
||||
local i='' card_plural='s' card_one='(1) '
|
||||
local i='' card_plural='s' card_one='(1) ' network_data=''
|
||||
|
||||
if [[ -n ${A_NETWORK_DATA[@]} ]]
|
||||
then
|
||||
|
@ -1259,10 +1266,12 @@ print_networking_data()
|
|||
card_one=''
|
||||
fi
|
||||
i=0
|
||||
print_screen_output "$( printf "${C1}%-${INDENT}s${C2} %s" "Network Card$card_plural" "${C1}$card_one${C2}${A_NETWORK_DATA[i]}" )"
|
||||
network_data=$( create_print_line "Network:" "${C1}$card_one${C2}${A_NETWORK_DATA[i]}" )
|
||||
print_screen_output "$network_data"
|
||||
while [[ -n ${A_NETWORK_DATA[++i]} ]]
|
||||
do
|
||||
print_screen_output "$( printf "${C1}%-${INDENT}s${C2} %s" " " "${C1}($(($i+1)))${C2} ${A_NETWORK_DATA[i]}" )"
|
||||
network_data=$( create_print_line " " "${C1}($(($i+1)))${C2} ${A_NETWORK_DATA[i]}" )
|
||||
print_screen_output "$network_data"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
@ -1315,7 +1324,7 @@ print_system_data()
|
|||
|
||||
# Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch!
|
||||
# long_last=$( echo -ne "${C1}Processes${C2} ${PROC}${CN} | ${C1}Uptime${C2} ${UPT}${CN} | ${C1}Memory${C2} ${MEM}${CN}" )
|
||||
system_data=$( printf "${C1}%-${INDENT}s${C2} %s" " " "${C1}Processes${C2} ${PROC}${CN} | ${C1}Uptime${C2} ${UPT}${CN} | ${C1}Memory${C2} ${MEM}${CN}" )
|
||||
system_data=$( printf "${C1}%-${INDENT}s${C2} %s" "Info:" "${C1}Processes${C2} ${PROC}${CN} | ${C1}Uptime${C2} ${UPT}${CN} | ${C1}Memory${C2} ${MEM}${CN}" )
|
||||
|
||||
if [ "$RUNLVL" -gt 0 ]
|
||||
then
|
||||
|
|
Loading…
Reference in a new issue