more refactoring, some bug fixes that made layout display wrong in editors

This commit is contained in:
inxi-svn 2008-10-28 02:48:05 +00:00
parent 04674b0e72
commit a5dd519b0f

71
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.1.5 #### version: 0.1.6
#### 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
@ -146,7 +146,7 @@ error_handler()
print_screen_output "$SCRIPT_NAME: large flood danger, debug buffer full!" print_screen_output "$SCRIPT_NAME: large flood danger, debug buffer full!"
;; ;;
3) 3)
print_screen_output "$SCRIPT_NAME: error in colorscheme, or unknown parameter: $2" print_screen_output "$SCRIPT_NAME: error in colorscheme - unsupported number: $2"
;; ;;
4) 4)
print_screen_output "$SCRIPT_NAME: unknown verbosity level $2" print_screen_output "$SCRIPT_NAME: unknown verbosity level $2"
@ -157,6 +157,9 @@ error_handler()
6) 6)
print_screen_output "$SCRIPT_NAME: /proc not found! Quitting..." print_screen_output "$SCRIPT_NAME: /proc not found! Quitting..."
;; ;;
7)
print_screen_output "$SCRIPT_NAME: unknown parameter: $2"
;;
*) *)
print_screen_output "$SCRIPT_NAME: error unknown: $@" print_screen_output "$SCRIPT_NAME: error unknown: $@"
set -- 99 set -- 99
@ -460,12 +463,16 @@ get_parameters()
exit 0 exit 0
;; ;;
*) *)
# these will need to be converted to standard type options
echo "$1" | grep -q '^[0-9][0-9]\?$' || error_handler 3 "$1" echo "$1" | grep -q '^[0-9][0-9]\?$' || error_handler 3 "$1"
if ! ((CSCHEME)) if ! ((CSCHEME))
then then
set_color_scheme "$1" set_color_scheme "$1"
fi fi
;; ;;
# *)
# error_handler 7 "$1"
# ;;
esac esac
shift shift
done done
@ -689,7 +696,7 @@ 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
@ -747,7 +754,8 @@ 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'; THDD=($(gawk ' IFS=$'\n'
THDD=($(gawk '
BEGIN { IGNORECASE=1 } BEGIN { IGNORECASE=1 }
/host/ { /host/ {
getline a[$0] getline a[$0]
@ -850,7 +858,10 @@ then
print(line) print(line)
} }
') ')
[[ -z $RES ]] && RES=$(xdpyinfo | gawk '/dimensions/ { print $2 }') if [[ -z $RES ]]
then
RES=$( xdpyinfo | gawk '/dimensions/ { print $2 }' )
fi
# X vendor and version detection. # X vendor and version detection.
XVENDOR=$( xdpyinfo | gawk -F': +' ' XVENDOR=$( xdpyinfo | gawk -F': +' '
@ -866,7 +877,9 @@ then
# Later on, the normal textual version string returned, e.g. like: X.Org version: 6.8.2 # Later on, the normal textual version string returned, e.g. like: X.Org version: 6.8.2
# A failover mechanism is in place. (if $XVERNUM is empty, the release number is parsed instead) # A failover mechanism is in place. (if $XVERNUM is empty, the release number is parsed instead)
XVERNUM=$( xdpyinfo | awk '/version:/ { print $NF }' ) XVERNUM=$( xdpyinfo | awk '/version:/ { print $NF }' )
[[ -z $XVERNUM ]] && XVERNUM=$(xdpyinfo | gawk -F': +' ' if [[ -z $XVERNUM ]]
then
XVERNUM=$(xdpyinfo | gawk -F': +' '
BEGIN { IGNORECASE=1 } BEGIN { IGNORECASE=1 }
/vendor release number/ { /vendor release number/ {
gsub(/0+$/,"",$2) gsub(/0+$/,"",$2)
@ -874,6 +887,7 @@ then
print $2 print $2
} }
') ')
fi
#X -version 2>&1 | gawk '/^X Window System Version/ { print $5 }' #X -version 2>&1 | gawk '/^X Window System Version/ { print $5 }'
#This method could be used in the future to detect X when X is not running, #This method could be used in the future to detect X when X is not running,
@ -913,12 +927,17 @@ then
} }
' ) ) ' ) )
IFS="$OIFS" IFS="$OIFS"
GLXR="${GLX[0]}"; GLXV="${GLX[1]}"; GLXDR="${GLX[2]}" GLXR="${GLX[0]}"
GLXV="${GLX[1]}"
GLXDR="${GLX[2]}"
# GLXR=$(glxinfo | gawk -F ': ' 'BEGIN {IGNORECASE=1} /opengl renderer/ && $2 !~ /mesa/ {seen[$2]++} END {for (i in seen) {printf("%s ",i)}}') # GLXR=$(glxinfo | gawk -F ': ' 'BEGIN {IGNORECASE=1} /opengl renderer/ && $2 !~ /mesa/ {seen[$2]++} END {for (i in seen) {printf("%s ",i)}}')
# GLXV=$(glxinfo | gawk -F ': ' 'BEGIN {IGNORECASE=1} /opengl version/ && $2 !~ /mesa/ {seen[$2]++} END {for (i in seen) {printf("%s ",i)}}') # GLXV=$(glxinfo | gawk -F ': ' 'BEGIN {IGNORECASE=1} /opengl version/ && $2 !~ /mesa/ {seen[$2]++} END {for (i in seen) {printf("%s ",i)}}')
[[ -z $GLXR || -z $GLXV ]] && MESA=1 if [[ -z $GLXR || -z $GLXV ]]
then
MESA=1
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 }' )
@ -937,7 +956,9 @@ then
print_screen_output "$LNINTRO" print_screen_output "$LNINTRO"
##print_screen_output "CPU[0]=\"${CPU[0]}\"" ##print_screen_output "CPU[0]=\"${CPU[0]}\""
IFS=","; CPUTMP=(${CPU[0]}); IFS="$OIFS" IFS=","
CPUTMP=(${CPU[0]})
IFS="$OIFS"
# Strange (and also some expected) behavior encountered. # 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>" # 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. # will output only <text1> and the first element of ARR. That "@" splits in elements and "*" _doesn't_, is to be expected.
@ -1088,13 +1109,37 @@ else # (IF VBL > 1 ... ELSE)
#set_color_scheme 12 #set_color_scheme 12
if ! ((IBSHELL)) if ! ((IBSHELL))
then then
for I in $C1 $C2 $CN ; do case "$I" in "$GREEN"|"$WHITE"|"$YELLOW"|"$CYAN") BGBLACK=1 ;; esac ; done for I in $C1 $C2 $CN
((BGBLACK)) && { for I in C1 C2 CN ; do [[ "${!I}" = "$NORMAL" ]] && declare $I="${!I}15,1" || declare $I="${!I},1" ; done ; } do
case "$I" in
"$GREEN"|"$WHITE"|"$YELLOW"|"$CYAN") BGBLACK=1
;;
esac
done
if ((BGBLACK))
then
for I in C1 C2 CN
do
if [[ "${!I}" = "$NORMAL" ]]
then
declare $I="${!I}15,1"
else
declare $I="${!I},1"
fi
done
#C1="${C1},1"; C2="${C2},1"; CN="${CN},1" #C1="${C1},1"; C2="${C2},1"; CN="${CN},1"
fi fi
fi
LNSHORT=$( echo -ne "${C1}CPU${CN}[${C2}${CPUMODEL} clocked at ${CPUCLOCK}${CN}] ${C1}Kernel${CN}[${C2}${OSKERN}${CN}] ${C1}Up${CN}[${C2}${FL2}${FL1}${UPT}${FL1}${CN}] ${C1}Mem${CN}[${C2}${FL2}${FL1}${MEM}${FL1}${CN}] ${C1}HDD${CN}[${C2}${FL2}${FL1}${HDD}($HDDUSG)${FL1}${CN}] ${C1}Procs${CN}[${C2}${FL2}${FL1}${PROC}${FL1}${CN}]" ) LNSHORT=$( echo -ne "${C1}CPU${CN}[${C2}${CPUMODEL} clocked at ${CPUCLOCK}${CN}] ${C1}Kernel${CN}[${C2}${OSKERN}${CN}] ${C1}Up${CN}[${C2}${FL2}${FL1}${UPT}${FL1}${CN}] ${C1}Mem${CN}[${C2}${FL2}${FL1}${MEM}${FL1}${CN}] ${C1}HDD${CN}[${C2}${FL2}${FL1}${HDD}($HDDUSG)${FL1}${CN}] ${C1}Procs${CN}[${C2}${FL2}${FL1}${PROC}${FL1}${CN}]" )
((SHOW_IRC)) && LNSHORT="${LNSHORT}$(echo -ne " ${C1}Client${CN}[${C2}${IRC}${IRCV}${CN}]")"
((SCHEME)) && LNSHORT="${LNSHORT}$(echo -ne "$NORMAL")" if ((SHOW_IRC))
then
LNSHORT="${LNSHORT}$( echo -ne " ${C1}Client${CN}[${C2}${IRC}${IRCV}${CN}]" )"
fi
if ((SCHEME))
then
LNSHORT="${LNSHORT}$( echo -ne "$NORMAL" )"
fi
print_screen_output "$LNSHORT" print_screen_output "$LNSHORT"
fi # (IF VBL > 1) fi # (IF VBL > 1)