Changed all cases of:

if [ .....]
then
or
elif [....]
then

to use the hanging then turd method:
if [....];then

This will be the standard style for inxi

All other flow controls will be on their own lines, ie:
do
done
{
}
This commit is contained in:
inxi-svn 2008-10-30 17:18:02 +00:00
parent 7085e1d702
commit b06b4a07c7

238
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.1.49 #### version: 0.1.50
#### Date: October 29 2008 #### Date: October 30 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
#### As time permits functionality and recoding will occur. #### As time permits functionality and recoding will occur.
@ -44,7 +44,7 @@ A_DISTRO_GLOB=''
IRC_CLIENT='' IRC_CLIENT=''
IRC_CLIENT_VERSION='' IRC_CLIENT_VERSION=''
X_VENDOR='' X_VENDOR=''
X_NUMBER='' X_VER_NUM=''
## primary data array holders ## primary data array holders
A_CPU_DATA='' A_CPU_DATA=''
@ -132,13 +132,11 @@ A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'
A_CPU_BANS=( cpu processor $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" ) A_CPU_BANS=( cpu processor $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
## Source global config overrides ## Source global config overrides
if [ -s /etc/$SCRIPT_NAME.conf ] if [ -s /etc/$SCRIPT_NAME.conf ];then
then
source /etc/$SCRIPT_NAME.conf source /etc/$SCRIPT_NAME.conf
fi fi
# Source user config overrides # Source user config overrides
if [ -s $HOME/.$SCRIPT_NAME ] if [ -s $HOME/.$SCRIPT_NAME ];then
then
source $HOME/.$SCRIPT_NAME source $HOME/.$SCRIPT_NAME
fi fi
@ -187,14 +185,11 @@ error_handler()
script_debugger() script_debugger()
{ {
if [ "$ALLUP" -gt 0 ] if [ "$ALLUP" -gt 0 ];then
then if [ "$DEBUG" -eq 0 ];then
if [ "$DEBUG" -eq 0 ]
then
return return
fi fi
if ((DBI)) if ((DBI));then
then
for (( DBI=0; DBI < ${#DBGBUF[@]}; DBI++ )) for (( DBI=0; DBI < ${#DBGBUF[@]}; DBI++ ))
do do
print_screen_output "${DBGBUF[DBI]}" print_screen_output "${DBGBUF[DBI]}"
@ -203,8 +198,7 @@ script_debugger()
fi fi
print_screen_output "$@" print_screen_output "$@"
else else
if ((!DEBUG_FLOOD && DBI > 10)) if ((!DEBUG_FLOOD && DBI > 10));then
then
error_handler 2 error_handler 2
fi fi
DBGBUF[DBI++]="$@" DBGBUF[DBI++]="$@"
@ -221,10 +215,8 @@ script_debugger()
# but that only works if infobash is being run as a konversation script to begin with # but that only works if infobash is being run as a konversation script to begin with
print_screen_output() print_screen_output()
{ {
if [ "$DEBUG" -gt 5 ] if [ "$DEBUG" -gt 5 ];then
then if [ "$KONVI" -eq 1 ];then
if [ "$KONVI" -eq 1 ]
then
dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$@'" dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$@'"
else else
echo "konvi='$KONVI' saying : '$@'" echo "konvi='$KONVI' saying : '$@'"
@ -234,8 +226,7 @@ print_screen_output()
fi fi
#((KONVI)) && dcop $DCPORT Konversation print_screen_output $DCSERVER "$DCTARGET" "$1" || echo -ne "$1\n" #((KONVI)) && dcop $DCPORT Konversation print_screen_output $DCSERVER "$DCTARGET" "$1" || echo -ne "$1\n"
if [ "$KONVI" -eq 1 ] if [ "$KONVI" -eq 1 ];then
then
dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "$1" dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "$1"
else else
echo -ne "$1\n" echo -ne "$1\n"
@ -285,13 +276,11 @@ check_script_depends()
{ {
local app_name='' local app_name=''
if [ ! -d /proc/ ] if [ ! -d /proc/ ];then
then
error_handler 6 error_handler 6
fi fi
if [ "$X" -gt 0 ] if [ "$X" -gt 0 ];then
then
for app_name in xrandr xdpyinfo glxinfo for app_name in xrandr xdpyinfo glxinfo
do do
type -p $app_name >/dev/null || { script_debugger "inxi: Resuming in non X mode: $app_name not found in path"; X=0; break; } type -p $app_name >/dev/null || { script_debugger "inxi: Resuming in non X mode: $app_name not found in path"; X=0; break; }
@ -314,8 +303,7 @@ make_bans()
for BANSTR for BANSTR
do do
#echo "BANSTR=\"$BANSTR\"" >&2 #echo "BANSTR=\"$BANSTR\"" >&2
if [[ ${BANSTR:0:1} = $'\2' ]] if [[ ${BANSTR:0:1} = $'\2' ]];then
then
MKBANS="${MKBANS}${MKBANS+|}${BANSTR:1:${#BANSTR}-1}" MKBANS="${MKBANS}${MKBANS+|}${BANSTR:1:${#BANSTR}-1}"
else else
# Automatically escapes [ ] ( ) . and + # Automatically escapes [ ] ( ) . and +
@ -331,13 +319,11 @@ set_color_scheme()
{ {
local i='' script_colors='' color_codes='' local i='' script_colors='' color_codes=''
if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]] if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]];then
then
set -- 1 set -- 1
fi fi
SCHEME="$1" # Set a global variable to allow checking for chosen scheme later SCHEME="$1" # Set a global variable to allow checking for chosen scheme later
if [ "$IBSHELL" -gt 0 ] if [ "$IBSHELL" -gt 0 ];then
then
color_codes=($ANSI_COLORS) color_codes=($ANSI_COLORS)
else else
color_codes=($IRC_COLORS) color_codes=($IRC_COLORS)
@ -360,8 +346,7 @@ get_cmdline()
{ {
local i=0 local i=0
if [ ! -e /proc/$1/cmdline ] if [ ! -e /proc/$1/cmdline ];then
then
{ echo 0; return; } { echo 0; return; }
fi fi
##print_screen_output "Marker" ##print_screen_output "Marker"
@ -372,11 +357,9 @@ get_cmdline()
CMDL[i++]="$L" ## note: make sure this is valid ## CMDL[i++]="$L" ## note: make sure this is valid ##
done </proc/$1/cmdline done </proc/$1/cmdline
##print_screen_output "\$i='$i'" ##print_screen_output "\$i='$i'"
if [ "$i" -eq 0 ] if [ "$i" -eq 0 ];then
then
CMDL[0]=$(< /proc/$1/cmdline) CMDL[0]=$(< /proc/$1/cmdline)
if [[ -n ${CMDL[0]} ]] if [[ -n ${CMDL[0]} ]];then
then
i=1 i=1
fi fi
fi fi
@ -401,12 +384,10 @@ get_parameters()
exec 2>&1 exec 2>&1
;; ;;
-v|-v[0-9]|--verbose) -v|-v[0-9]|--verbose)
if [[ ${#1} -eq 3 ]] if [[ ${#1} -eq 3 ]];then
then
VERBOSITY_LEVEL="${1:2}" VERBOSITY_LEVEL="${1:2}"
else else
if [[ $2 = --* || $2 = -* || -z $2 ]] if [[ $2 = --* || $2 = -* || -z $2 ]];then
then
VERBOSITY_LEVEL=1 VERBOSITY_LEVEL=1
else else
shift shift
@ -429,8 +410,7 @@ get_parameters()
# these will need to be converted to standard type options # 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"
COLOR_SCHEME_SET='true' COLOR_SCHEME_SET='true'
if [ -z "$COLOR_SCHEME" ] if [ -z "$COLOR_SCHEME" ];then
then
set_color_scheme "$1" set_color_scheme "$1"
fi fi
;; ;;
@ -492,18 +472,15 @@ get_start_source()
{ {
local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i='' local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i=''
if tty >/dev/null if tty >/dev/null;then
then
IRC_CLIENT="Shell" IRC_CLIENT="Shell"
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
IBSHELL=1 IBSHELL=1
elif [ -n "$PPID" -a -f "/proc/$PPID/exe" ] elif [ -n "$PPID" -a -f "/proc/$PPID/exe" ];then
then
irc_client_path=$( readlink /proc/$PPID/exe ) irc_client_path=$( readlink /proc/$PPID/exe )
# this handles the problem with konversation reporting itself as perl, which was missed because # this handles the problem with konversation reporting itself as perl, which was missed because
# when konversation starts infobash from inside itself, as a script, the parent is konversation, not perl # when konversation starts infobash from inside itself, as a script, the parent is konversation, not perl
if [ -z "$( grep -i 'konversation' <<< $irc_client_path )" -a -n "$( grep -i 'perl' <<< $irc_client_path )" -a -n "$( pidof konversation )" ] if [ -z "$( grep -i 'konversation' <<< $irc_client_path )" -a -n "$( grep -i 'perl' <<< $irc_client_path )" -a -n "$( pidof konversation )" ];then
then
irc_client_path=$( which konversation ) irc_client_path=$( which konversation )
non_native_konvi='true' non_native_konvi='true'
fi fi
@ -516,16 +493,14 @@ get_start_source()
;; ;;
*konversation*) *konversation*)
# this is necessary to avoid the dcop errors from starting inxi as a /cmd started script # this is necessary to avoid the dcop errors from starting inxi as a /cmd started script
if [ "$non_native_konvi" == 'true' ] if [ "$non_native_konvi" == 'true' ];then
then
KONVI=2 KONVI=2
else else
KONVI=1 KONVI=1
fi fi
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '/Konversation:/ { for (i=2;i<=NF;i++) { if (i == NF) { print $i } else { printf $i" " } } exit }' )" IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '/Konversation:/ { for (i=2;i<=NF;i++) { if (i == NF) { print $i } else { printf $i" " } } exit }' )"
T=($IRC_CLIENT_VERSION) T=($IRC_CLIENT_VERSION)
if [[ ${T[0]} == *+* ]] if [[ ${T[0]} == *+* ]];then
then
# < Sho_> locsmif: The version numbers of SVN versions look like this: # < Sho_> locsmif: The version numbers of SVN versions look like this:
# "<version number of last release>+ #<build number", i.e. "1.0+ #3177" ... # "<version number of last release>+ #<build number", i.e. "1.0+ #3177" ...
# for releases we remove the + and build number, i.e. "1.0" or soon "1.0.1" # for releases we remove the + and build number, i.e. "1.0" or soon "1.0.1"
@ -540,8 +515,7 @@ get_start_source()
# Since Konversation 1.0, the DCOP interface has changed a bit: dcop "$DCPORT" Konversation ..etc # Since Konversation 1.0, the DCOP interface has changed a bit: dcop "$DCPORT" Konversation ..etc
# becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller # becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller
# than 1 and change the DCOP parameter/object accordingly. # than 1 and change the DCOP parameter/object accordingly.
if [[ ${T2} < 1 ]] if [[ ${T2} < 1 ]];then
then
DCOPOBJ="Konversation" DCOPOBJ="Konversation"
fi fi
IRC_CLIENT="Konversation" IRC_CLIENT="Konversation"
@ -606,8 +580,7 @@ get_start_source()
;; ;;
esac esac
done done
if [ -z "$IRC_CLIENT_VERSION" ] if [ -z "$IRC_CLIENT_VERSION" ];then
then
IRC_CLIENT="Unknown Perl client" IRC_CLIENT="Unknown Perl client"
fi fi
;; ;;
@ -620,8 +593,7 @@ get_start_source()
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
;; ;;
esac esac
if [ "$SHOW_IRC" -lt 2 ] if [ "$SHOW_IRC" -lt 2 ];then
then
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
fi fi
else else
@ -636,8 +608,7 @@ set_calculated_variables()
# Extra path variable to make execute failures less likely, merged below # Extra path variable to make execute failures less likely, merged below
local extra_paths="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" local extra_paths="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
# Detect X and set variable "X" accordingly # Detect X and set variable "X" accordingly
if [ -n "$DISPLAY" ] if [ -n "$DISPLAY" ];then
then
X=1 X=1
fi fi
@ -649,13 +620,11 @@ set_calculated_variables()
FLAG=0 FLAG=0
for sys_path in $PATH for sys_path in $PATH
do do
if [ "$path" == "$sys_path" ] if [ "$path" == "$sys_path" ];then
then
FLAG=1 FLAG=1
fi fi
done done
if [ "$FLAG" -eq 0 ] if [ "$FLAG" -eq 0 ];then
then
added_path="$added_path:$path" added_path="$added_path:$path"
fi fi
done done
@ -670,7 +639,6 @@ set_calculated_variables()
##echo "A_NORMAL_BANS='$A_NORMAL_BANS'" ##echo "A_NORMAL_BANS='$A_NORMAL_BANS'"
} }
#### ------------------------------------------------------------------- #### -------------------------------------------------------------------
#### get data types #### get data types
#### ------------------------------------------------------------------- #### -------------------------------------------------------------------
@ -736,8 +704,7 @@ get_cpu_data()
# I use all these loops so I can easily extend the cpu array created in the awk script above with more fields per cpu. # I use all these loops so I can easily extend the cpu array created in the awk script above with more fields per cpu.
for (( j=0; j < ${#a_cpu_working[@]}; j++ )) for (( j=0; j < ${#a_cpu_working[@]}; j++ ))
do do
if [ "$j" -gt 0 ] if [ "$j" -gt 0 ];then
then
A_CPU_DATA[i]="${A_CPU_DATA[i]},${a_cpu_working[j]}" A_CPU_DATA[i]="${A_CPU_DATA[i]},${a_cpu_working[j]}"
else else
A_CPU_DATA[i]="${a_cpu_working[j]}" A_CPU_DATA[i]="${a_cpu_working[j]}"
@ -746,8 +713,7 @@ get_cpu_data()
done done
# test for multi core cpu present # test for multi core cpu present
multi_cpu=$( grep -i 'dual\|triple\|quad' <<< "${A_CPU_DATA[@]}" ) multi_cpu=$( grep -i 'dual\|triple\|quad' <<< "${A_CPU_DATA[@]}" )
if [ -n "$multi_cpu" ] if [ -n "$multi_cpu" ];then
then
NO_CPU_COUNT=1 NO_CPU_COUNT=1
else else
case $(( ${#A_CPU_DATA[@]}-1 )) in case $(( ${#A_CPU_DATA[@]}-1 )) in
@ -810,8 +776,7 @@ get_cpu_data()
' ) ' )
#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
} }
@ -827,25 +792,21 @@ get_distro_data()
cd "$OLDPWD" cd "$OLDPWD"
shopt -u nullglob shopt -u nullglob
if (( ${#A_DISTRO_GLOB[@]} == 1 )) if (( ${#A_DISTRO_GLOB[@]} == 1 ));then
then
DISTRO_FILE="${A_DISTRO_GLOB}" DISTRO_FILE="${A_DISTRO_GLOB}"
elif (( ${#A_DISTRO_GLOB[@]} > 1 )) elif (( ${#A_DISTRO_GLOB[@]} > 1 ));then
then
for i in $DISTROS_DERIVED $DISTROS_PRIMARY for i in $DISTROS_DERIVED $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()
# This is a known bug, search for the word "strange" inside comments # This is a known bug, search for the word "strange" inside comments
# echo "i='$i' A_DISTRO_GLOB[@]='${A_DISTRO_GLOB[@]}'" # echo "i='$i' A_DISTRO_GLOB[@]='${A_DISTRO_GLOB[@]}'"
if [[ " ${A_DISTRO_GLOB[@]} " == *" $i "* ]] if [[ " ${A_DISTRO_GLOB[@]} " == *" $i "* ]];then
then
DISTRO_FILE="${i}" DISTRO_FILE="${i}"
break break
fi fi
done done
fi fi
if [ -n "$DISTRO_FILE" -a -s /etc/$DISTRO_FILE -a " $DISTROS_BLIST " != *" $DISTRO_FILE "* ] if [ -n "$DISTRO_FILE" -a -s /etc/$DISTRO_FILE -a " $DISTROS_BLIST " != *" $DISTRO_FILE "* ];then
then
DISTRO=$( remove_erroneous_chars "/etc/$DISTRO_FILE" ) DISTRO=$( remove_erroneous_chars "/etc/$DISTRO_FILE" )
else else
# Debian pure should fall through here # Debian pure should fall through here
@ -855,8 +816,7 @@ get_distro_data()
gsub(/^ +| +$/,""); gsub(/^ +| +$/,"");
print }' "/etc/${DISTRO_FILE}" ) print }' "/etc/${DISTRO_FILE}" )
fi fi
if (( ${#DISTRO} > 80 && ! CRAP )) if (( ${#DISTRO} > 80 && ! CRAP ));then
then
DISTRO="${RED}/etc/${DISTRO_FILE} corrupted, use --crap to override${NORMAL}" DISTRO="${RED}/etc/${DISTRO_FILE} corrupted, use --crap to override${NORMAL}"
fi fi
## note: figure out a more readable way to achieve whatever is intended here ## ## note: figure out a more readable way to achieve whatever is intended here ##
@ -877,8 +837,7 @@ get_graphics_data()
# 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" -gt 0 ] if [ "$X" -gt 0 ];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 '
@ -893,8 +852,7 @@ get_graphics_data()
} }
' ) ' )
if [ -z "$RES" ] if [ -z "$RES" ];then
then
RES=$( xdpyinfo | gawk '/dimensions/ { print $2 }' ) RES=$( xdpyinfo | gawk '/dimensions/ { print $2 }' )
fi fi
@ -912,8 +870,7 @@ get_graphics_data()
# 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 $X_VER_NUM is empty, the release number is parsed instead) # A failover mechanism is in place. (if $X_VER_NUM is empty, the release number is parsed instead)
X_VER_NUM=$( xdpyinfo | awk '/version:/ { print $NF }' ) X_VER_NUM=$( xdpyinfo | awk '/version:/ { print $NF }' )
if [ -z "$X_VER_NUM" ] if [ -z "$X_VER_NUM" ];then
then
X_VER_NUM=$(xdpyinfo | gawk -F': +' ' X_VER_NUM=$(xdpyinfo | gawk -F': +' '
BEGIN { IGNORECASE=1 } BEGIN { IGNORECASE=1 }
/vendor release number/ { /vendor release number/ {
@ -968,8 +925,7 @@ get_graphics_data()
# 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)}}')
if [ -z "$GLXR" -o -z "$GLXV" ] if [ -z "$GLXR" -o -z "$GLXV" ];then
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)
@ -985,11 +941,9 @@ get_hard_drive_data()
for disk in /proc/ide/ide*/hd* for disk in /proc/ide/ide*/hd*
do do
if [[ -e $disk/media && $( remove_erroneous_chars $disk/media ) = disk ]] if [[ -e $disk/media && $( remove_erroneous_chars $disk/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
if [[ ! -e $disk/capacity ]] if [[ ! -e $disk/capacity ]];then
then
CAP=0 CAP=0
break break
fi fi
@ -998,8 +952,7 @@ get_hard_drive_data()
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'
@ -1031,8 +984,7 @@ get_hard_drive_data()
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
@ -1042,13 +994,11 @@ get_hard_drive_data()
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" -gt 0 ] if [ "$HDD" -gt 0 ];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]+)/) {
@ -1151,21 +1101,18 @@ print_cpu_data()
# The above mentioned only emerges when using the debugging markers below # The above mentioned only emerges when using the debugging markers below
##print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------" ##print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
if [[ -z ${a_cpu_working[2]} ]] if [[ -z ${a_cpu_working[2]} ]];then
then
a_cpu_working[2]="unknown" a_cpu_working[2]="unknown"
fi fi
if [[ ${#A_CPU_DATA[@]} -gt 2 ]] if [[ ${#A_CPU_DATA[@]} -gt 2 ]];then
then
cpu_number="${C1}(1)${C2} " cpu_number="${C1}(1)${C2} "
else else
# Array CPU always has one element: max clockfreq found. Therefore -gt and not -ge # Array CPU always has one element: max clockfreq found. Therefore -gt and not -ge
unset cpu_number unset cpu_number
fi fi
cpu_data=$( create_print_line "CPU:" "${cpu_number}${a_cpu_working[0]}" ) cpu_data=$( create_print_line "CPU:" "${cpu_number}${a_cpu_working[0]}" )
if [ "$VERBOSITY_LEVEL" -ge 3 ] if [ "$VERBOSITY_LEVEL" -ge 3 ];then
then
cpu_data="$cpu_data${C2} ${a_cpu_working[2]} cache${C2} ${C1}flags${C2} ($CPUFLAGS)${CN}" cpu_data="$cpu_data${C2} ${a_cpu_working[2]} cache${C2} ${C1}flags${C2} ($CPUFLAGS)${CN}"
fi fi
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}"
@ -1177,14 +1124,12 @@ print_cpu_data()
a_cpu_working=(${A_CPU_DATA[i]}) a_cpu_working=(${A_CPU_DATA[i]})
IFS="$OIFS" IFS="$OIFS"
cpu_data=$( create_print_line " " "${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 ] if [ "$VERBOSITY_LEVEL" -ge 3 ];then
then
cpu_data="$cpu_data${C2} ${a_cpu_working[2]} cache${C2} ${C1}flags${C2} ($CPUFLAGS)${CN}" cpu_data="$cpu_data${C2} ${a_cpu_working[2]} cache${C2} ${C1}flags${C2} ($CPUFLAGS)${CN}"
fi fi
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}"
print_screen_output "$cpu_data" print_screen_output "$cpu_data"
if [ "$i" -gt 10 ] if [ "$i" -gt 10 ];then
then
break break
fi fi
done done
@ -1194,8 +1139,7 @@ print_gfx_data()
{ {
local gfx_data='' i='' card_one='Card ' local gfx_data='' i='' card_one='Card '
if [[ ${#A_GFX_DATA[@]} -gt 1 ]] if [[ ${#A_GFX_DATA[@]} -gt 1 ]];then
then
i=1 i=1
while [[ -n ${A_GFX_DATA[i]} && $i -le 3 ]] while [[ -n ${A_GFX_DATA[i]} && $i -le 3 ]]
do do
@ -1206,20 +1150,16 @@ print_gfx_data()
fi fi
gfx_data=$( create_print_line "Graphics:" "${C1}$card_one${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 ] if [ "$X" -gt 0 ];then
then
gfx_data="${gfx_data} ${CN}| ${C1}$X_VENDOR${C2} $X_VER_NUM ${CN}| ${C1}Res${C2} ${RES}" gfx_data="${gfx_data} ${CN}| ${C1}$X_VENDOR${C2} $X_VER_NUM ${CN}| ${C1}Res${C2} ${RES}"
else else
gfx_data="${gfx_data} ${C1} tty resolution ${CN}(${C2} ${RES} ${CN})" gfx_data="${gfx_data} ${C1} tty resolution ${CN}(${C2} ${RES} ${CN})"
fi fi
print_screen_output "$gfx_data" print_screen_output "$gfx_data"
# echo x$X m$MESA
# echo GLXR$GLXR GLXV$GLXV if [ "$X" -gt 0 -a "$MESA" -eq 0 ];then
if [ "$X" -gt 0 -a "$MESA" -eq 0 ]
then
gfx_data=$( create_print_line " " "${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" -gt 0 ] if [ "$CRAP" -gt 0 ];then
then
gfx_data="${gfx_data} ${C1}Direct rendering${C2} ${GLXDR}${CN}" gfx_data="${gfx_data} ${C1}Direct rendering${C2} ${GLXDR}${CN}"
fi fi
print_screen_output "$gfx_data" print_screen_output "$gfx_data"
@ -1232,16 +1172,14 @@ print_hard_disk_data()
local root_home_data="$( df -h -T | egrep '(/|/boot|/var|/home)$' | C1=${C1} C2=${C2} awk '{print ENVIRON["C1"]"Partition:"ENVIRON["C2"], $7, ENVIRON["C1"]"- ", ENVIRON["C1"]"size:"ENVIRON["C2"], $3, ENVIRON["C1"]"used:"ENVIRON["C2"], $4, "(", $6, ")"}' )" local root_home_data="$( df -h -T | egrep '(/|/boot|/var|/home)$' | C1=${C1} C2=${C2} awk '{print ENVIRON["C1"]"Partition:"ENVIRON["C2"], $7, ENVIRON["C1"]"- ", ENVIRON["C1"]"size:"ENVIRON["C2"], $3, ENVIRON["C1"]"used:"ENVIRON["C2"], $4, "(", $6, ")"}' )"
root_home_data=$( echo $root_home_data ) root_home_data=$( echo $root_home_data )
if [ "$VERBOSITY_LEVEL" -ge 2 ] if [ "$VERBOSITY_LEVEL" -ge 2 ];then
then
hdd_data=$( create_print_line "Disks:" "${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 else
hdd_data=$( create_print_line "Disks:" "${C1}HDD Size${C2} ${HDD} (${HDDUSG})${CN}" ) hdd_data=$( create_print_line "Disks:" "${C1}HDD Size${C2} ${HDD} (${HDDUSG})${CN}" )
fi fi
print_screen_output "$hdd_data" print_screen_output "$hdd_data"
if [ "$VERBOSITY_LEVEL" -ge 4 ] if [ "$VERBOSITY_LEVEL" -ge 4 ];then
then
hdd_data=$( create_print_line " " "${root_home_data}" ) hdd_data=$( create_print_line " " "${root_home_data}" )
print_screen_output "$hdd_data" print_screen_output "$hdd_data"
fi fi
@ -1251,8 +1189,7 @@ print_intro_data()
{ {
local intro_data='' host_name=$( hostname ) local intro_data='' host_name=$( hostname )
if [ "$SHOW_HOST" -gt 0 ] if [ "$SHOW_HOST" -gt 0 ];then
then
intro_data=$( create_print_line "System:" "${C1}Host${C2} $host_name ${C1}running${C2} ${CN}" ) intro_data=$( create_print_line "System:" "${C1}Host${C2} $host_name ${C1}running${C2} ${CN}" )
else else
intro_data=$( create_print_line "System:" "${C1}running${C2} ${CN}" ) intro_data=$( create_print_line "System:" "${C1}running${C2} ${CN}" )
@ -1265,10 +1202,8 @@ print_networking_data()
{ {
local i='' card_plural='s' card_one='Card-1 ' network_data='' local i='' card_plural='s' card_one='Card-1 ' network_data=''
if [[ -n ${A_NETWORK_DATA[@]} ]] if [[ -n ${A_NETWORK_DATA[@]} ]];then
then if [[ ${#A_NETWORK_DATA[@]} -le 1 ]];then
if [[ ${#A_NETWORK_DATA[@]} -le 1 ]]
then
card_plural='' card_plural=''
card_one='' card_one=''
fi fi
@ -1288,8 +1223,7 @@ print_short_data()
local short_data='' i='' local short_data='' i=''
#set_color_scheme 12 #set_color_scheme 12
if [ "$IBSHELL" -eq 0 ] if [ "$IBSHELL" -eq 0 ];then
then
for i in $C1 $C2 $CN for i in $C1 $C2 $CN
do do
case "$i" in case "$i" in
@ -1297,12 +1231,10 @@ print_short_data()
;; ;;
esac esac
done done
if [ "$BGBLACK" -gt 0 ] if [ "$BGBLACK" -gt 0 ];then
then
for i in C1 C2 CN for i in C1 C2 CN
do do
if [[ "${!i}" = "$NORMAL" ]] if [[ "${!i}" = "$NORMAL" ]];then
then
declare $i="${!i}15,1" declare $i="${!i}15,1"
else else
declare $i="${!i},1" declare $i="${!i},1"
@ -1313,13 +1245,11 @@ print_short_data()
fi fi
short_data="${C1}CPU${CN}[${C2}${CPUMODEL} clocked at ${CPUCLOCK}${CN}] ${C1}Kernel${CN}[${C2}${CURRENT_KERNEL}${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}]" short_data="${C1}CPU${CN}[${C2}${CPUMODEL} clocked at ${CPUCLOCK}${CN}] ${C1}Kernel${CN}[${C2}${CURRENT_KERNEL}${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}]"
if [ "$SHOW_IRC" -gt 0 ] if [ "$SHOW_IRC" -gt 0 ];then
then
short_data="${short_data} ${C1}Client${CN}[${C2}${IRC_CLIENT}${IRC_CLIENT_VERSION}${CN}]" short_data="${short_data} ${C1}Client${CN}[${C2}${IRC_CLIENT}${IRC_CLIENT_VERSION}${CN}]"
fi fi
short_data="${short_data} ${CN}:: ${C1}$SCRIPT_NAME ${C2}v:$SCRIPT_VERSION_NUMBER${CN}" short_data="${short_data} ${CN}:: ${C1}$SCRIPT_NAME ${C2}v:$SCRIPT_VERSION_NUMBER${CN}"
if [ "$SCHEME" -gt 0 ] if [ "$SCHEME" -gt 0 ];then
then
short_data="${short_data} $NORMAL" short_data="${short_data} $NORMAL"
fi fi
print_screen_output "$short_data" print_screen_output "$short_data"
@ -1333,19 +1263,16 @@ print_system_data()
# long_last=$( echo -ne "${C1}Processes${C2} ${PROC}${CN} | ${C1}Uptime${C2} ${UPT}${CN} | ${C1}Memory${C2} ${MEM}${CN}" ) # long_last=$( echo -ne "${C1}Processes${C2} ${PROC}${CN} | ${C1}Uptime${C2} ${UPT}${CN} | ${C1}Memory${C2} ${MEM}${CN}" )
system_data=$( create_print_line "Info:" "${C1}Processes${C2} ${PROC} ${CN}| ${C1}Uptime${C2} ${UPT} ${CN}| ${C1}Memory${C2} ${MEM}${CN}" ) system_data=$( create_print_line "Info:" "${C1}Processes${C2} ${PROC} ${CN}| ${C1}Uptime${C2} ${UPT} ${CN}| ${C1}Memory${C2} ${MEM}${CN}" )
if [ "$RUNLVL" -gt 0 ] if [ "$RUNLVL" -gt 0 ];then
then
system_data="${system_data} ${CN}| ${C1}Runlevel${C2} ${RUNLVL}${CN}" system_data="${system_data} ${CN}| ${C1}Runlevel${C2} ${RUNLVL}${CN}"
fi fi
if [ "$SHOW_IRC" -gt 0 ] if [ "$SHOW_IRC" -gt 0 ];then
then
system_data="${system_data} ${CN}| ${C1}Client${C2} ${IRC_CLIENT}${IRC_CLIENT_VERSION}${CN}" system_data="${system_data} ${CN}| ${C1}Client${C2} ${IRC_CLIENT}${IRC_CLIENT_VERSION}${CN}"
fi fi
system_data="${system_data} ${CN}| ${C1}$SCRIPT_NAME ${C2}v:$SCRIPT_VERSION_NUMBER${CN}" system_data="${system_data} ${CN}| ${C1}$SCRIPT_NAME ${C2}v:$SCRIPT_VERSION_NUMBER${CN}"
if [ "$SCHEME" -gt 0 ] if [ "$SCHEME" -gt 0 ];then
then
system_data="${system_data} ${NORMAL}" system_data="${system_data} ${NORMAL}"
fi fi
print_screen_output "$system_data" print_screen_output "$system_data"
@ -1362,8 +1289,7 @@ print_it_out()
print_cpu_data print_cpu_data
print_gfx_data print_gfx_data
if [ "$VERBOSITY_LEVEL" -ge 2 ] if [ "$VERBOSITY_LEVEL" -ge 2 ];then
then
print_networking_data print_networking_data
fi fi
@ -1384,8 +1310,7 @@ get_start_source
# note: this only works if it's run from inside konversation as a script builtin or something # note: this only works if it's run from inside konversation as a script builtin or something
# only do this if inxi has been started as a konversation script, otherwise bypass this # only do this if inxi has been started as a konversation script, otherwise bypass this
if [ "$KONVI" -eq 1 ] if [ "$KONVI" -eq 1 ];then
then
DCPORT="$1" DCPORT="$1"
DCSERVER="$2" DCSERVER="$2"
DCTARGET="$3" DCTARGET="$3"
@ -1395,8 +1320,7 @@ then
IFS=":" IFS=":"
for kde_config in $( kde-config --path data ) for kde_config in $( kde-config --path data )
do do
if [[ -r ${kde_config}${KONVI_CFG} ]] if [[ -r ${kde_config}${KONVI_CFG} ]];then
then
source "${kde_config}${KONVI_CFG}" source "${kde_config}${KONVI_CFG}"
break break
fi fi
@ -1411,8 +1335,7 @@ fi
get_parameters "$@" get_parameters "$@"
# If no colorscheme was set in the parameter handling routine, then set the default scheme # If no colorscheme was set in the parameter handling routine, then set the default scheme
if [ "$COLOR_SCHEME_SET" != 'true' ] if [ "$COLOR_SCHEME_SET" != 'true' ];then
then
set_color_scheme "$DEFAULT_SCHEME" set_color_scheme "$DEFAULT_SCHEME"
fi fi
@ -1432,8 +1355,7 @@ get_graphics_data
print_it_out print_it_out
## last steps ## last steps
if [ "$IBSHELL" -gt 0 -a "$SCHEME" -gt 0 ] if [ "$IBSHELL" -gt 0 -a "$SCHEME" -gt 0 ];then
then
echo -n "" echo -n ""
fi fi