Made all if conditionals use the same syntax, [[.....]];then, since we couldn't get rid of all the [[ stuff without

getting errors, it should all be the same, so [[....]] it is. Also cleaned up some other cruft and reorganized code 
slightly.
This commit is contained in:
inxi-svn 2008-11-06 19:43:28 +00:00
parent 1169e86347
commit 3873d50e86

204
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.3.24 #### version: 0.3.25
#### Date: November 5 2008 #### Date: November 5 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
@ -80,8 +80,11 @@ B_RUNNING_IN_SHELL='false'
B_SHOW_HOST='true' B_SHOW_HOST='true'
# triggers various debugging and new option testing # triggers various debugging and new option testing
B_TESTING_FLAG='false' B_TESTING_FLAG='false'
# Assume X not running until tests show it is # Test for X running
B_X_RUNNING='false' B_X_RUNNING='false'
if [[ -n $DISPLAY ]];then
B_X_RUNNING='true'
fi
### Variable initializations: constants ### Variable initializations: constants
DCOPOBJ="default" DCOPOBJ="default"
@ -89,7 +92,7 @@ DEBUG=0 # Set debug levels from 1-10
# Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up' # Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up'
DEBUG_BUFFER_INDEX=0 DEBUG_BUFFER_INDEX=0
### Reroute all error messages to the bitbucket (if not debugging) ### Reroute all error messages to the bitbucket (if not debugging)
if [ "$DEBUG" -eq 0 ] if [[ $DEBUG -eq 0 ]]
then then
exec 2>/dev/null exec 2>/dev/null
fi fi
@ -170,11 +173,11 @@ A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'
A_CPU_BANS=( @ cpu deca 'dual core' 'tri core' 'quad core' ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" ) A_CPU_BANS=( @ cpu deca 'dual core' 'tri core' 'quad core' ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
### Source global config overrides ### Source global config overrides
if [ -s /etc/$SCRIPT_NAME.conf ];then if [[ -s /etc/$SCRIPT_NAME.conf ]];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 ];then if [[ -s $HOME/.$SCRIPT_NAME ]];then
source $HOME/.$SCRIPT_NAME source $HOME/.$SCRIPT_NAME
fi fi
@ -234,11 +237,11 @@ script_debugger()
{ {
local a_debug_buffer='' local a_debug_buffer=''
if [ "$B_ALL_UP" == 'true' ];then if [[ $B_ALL_UP == 'true' ]];then
if [ "$DEBUG" -eq 0 ];then if [[ $DEBUG -eq 0 ]];then
return return
fi fi
if [ "$DEBUG_BUFFER_INDEX" -gt 0 ];then if [[ $DEBUG_BUFFER_INDEX -gt 0 ]];then
for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#a_debug_buffer[@]}; DEBUG_BUFFER_INDEX++ )) for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#a_debug_buffer[@]}; DEBUG_BUFFER_INDEX++ ))
do do
print_screen_output "${a_debug_buffer[DEBUG_BUFFER_INDEX]}" print_screen_output "${a_debug_buffer[DEBUG_BUFFER_INDEX]}"
@ -247,7 +250,7 @@ script_debugger()
fi fi
print_screen_output "$@" print_screen_output "$@"
else else
if [ "$B_DEBUG_FLOOD" == 'true' -a "$DEBUG_BUFFER_INDEX" -gt 10 ];then if [[ $B_DEBUG_FLOOD == 'true' && $DEBUG_BUFFER_INDEX -gt 10 ]];then
error_handler 2 error_handler 2
fi fi
a_debug_buffer[DEBUG_BUFFER_INDEX++]="$@" a_debug_buffer[DEBUG_BUFFER_INDEX++]="$@"
@ -264,8 +267,8 @@ script_debugger()
# but that only works if inxi is being run as a konversation script to begin with # but that only works if inxi is being run as a konversation script to begin with
print_screen_output() print_screen_output()
{ {
if [ "$DEBUG" -gt 5 ];then if [[ $DEBUG -gt 5 ]];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 : '$@'"
@ -275,7 +278,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 ];then if [[ $KONVI -eq 1 ]];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"
@ -328,15 +331,15 @@ check_script_depends()
{ {
local app_name='' app_data='' local app_name='' app_data=''
if [ ! -d /proc/ ];then if [[ ! -d /proc/ ]];then
error_handler 6 error_handler 6
fi fi
if [ "$B_X_RUNNING" == 'true' ];then if [[ $B_X_RUNNING == 'true' ]];then
for app_name in xrandr xdpyinfo glxinfo for app_name in xrandr xdpyinfo glxinfo
do do
app_data=$( type -p $app_name ) app_data=$( type -p $app_name )
if [ -z "$app_data" ];then if [[ -z $app_data ]];then
script_debugger "inxi: Resuming in non X mode: $app_name not found in path" script_debugger "inxi: Resuming in non X mode: $app_name not found in path"
B_X_RUNNING='false' B_X_RUNNING='false'
break break
@ -349,7 +352,7 @@ check_script_depends()
for app_name in df free gawk grep hostname lspci ps readlink runlevel tr uname uptime wc for app_name in df free gawk grep hostname lspci ps readlink runlevel tr uname uptime wc
do do
app_data=$( type -p $app_name ) app_data=$( type -p $app_name )
if [ -z "$app_data" ];then if [[ -z $app_data ]];then
error_handler 5 "$app_name" error_handler 5 "$app_name"
fi fi
done done
@ -387,7 +390,7 @@ set_color_scheme()
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 [ "$B_RUNNING_IN_SHELL" == 'true' ];then if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
color_codes=( $ANSI_COLORS ) color_codes=( $ANSI_COLORS )
else else
color_codes=( $IRC_COLORS ) color_codes=( $IRC_COLORS )
@ -411,7 +414,7 @@ get_cmdline()
{ {
local i=0 ppid=$1 local i=0 ppid=$1
if [ ! -e /proc/$ppid/cmdline ];then if [[ ! -e /proc/$ppid/cmdline ]];then
echo 0 echo 0
return return
fi fi
@ -424,7 +427,7 @@ get_cmdline()
A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ## A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ##
done </proc/$ppid/cmdline done </proc/$ppid/cmdline
##print_screen_output "\$i='$i'" ##print_screen_output "\$i='$i'"
if [ "$i" -eq 0 ];then if [[ $i -eq 0 ]];then
A_CMDL[0]=$(< /proc/$ppid/cmdline) A_CMDL[0]=$(< /proc/$ppid/cmdline)
if [[ -n ${A_CMDL[0]} ]];then if [[ -n ${A_CMDL[0]} ]];then
i=1 i=1
@ -439,18 +442,18 @@ get_parameters()
{ {
local opt='' local opt=''
if [ -z "$1" ];then if [[ -z $1 ]];then
return 1 return 1
fi fi
while getopts c:CdDfhTUv:Vx opt while getopts c:CdDfhTUv:Vx opt
do do
case $opt in case $opt in
c) if [ -n "$( egrep '^[0-9][0-9]?$' <<< $OPTARG )" ];then c) if [[ -n $( egrep '^[0-9][0-9]?$' <<< $OPTARG ) ]];then
COLOR_SCHEME_SET='true' COLOR_SCHEME_SET='true'
## note: not sure about this, you'd think user values should be overridden, but ## note: not sure about this, you'd think user values should be overridden, but
## we'll leave this for now ## we'll leave this for now
if [ -z "$COLOR_SCHEME" ];then if [[ -z $COLOR_SCHEME ]];then
set_color_scheme "$OPTARG" set_color_scheme "$OPTARG"
fi fi
else else
@ -550,7 +553,7 @@ script_self_updater()
print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER" print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER"
print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH now..." print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH now..."
wget -O $SCRIPT_PATH/$SCRIPT_NAME http://techpatterns.com/downloads/distro/$SCRIPT_NAME || error_handler 8 "$?" wget -O $SCRIPT_PATH/$SCRIPT_NAME http://techpatterns.com/downloads/distro/$SCRIPT_NAME || error_handler 8 "$?"
if [ "$?" -eq 0 ];then if [[ $? -eq 0 ]];then
SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3}' ) SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3}' )
print_screen_output "Successfully updated to version: $SCRIPT_VERSION_NUMBER\nTo run the new version, just start $SCRIPT_NAME again." print_screen_output "Successfully updated to version: $SCRIPT_VERSION_NUMBER\nTo run the new version, just start $SCRIPT_NAME again."
exit 0 exit 0
@ -566,7 +569,7 @@ script_self_updater()
#### ------------------------------------------------------------------- #### -------------------------------------------------------------------
# Determine where inxi was run from, set IRC_CLIENT and IRC_CLIENT_VERSION # Determine where inxi was run from, set IRC_CLIENT and IRC_CLIENT_VERSION
get_start_source() get_start_client()
{ {
local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i='' local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i=''
@ -574,11 +577,11 @@ get_start_source()
IRC_CLIENT="Shell" IRC_CLIENT="Shell"
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
B_RUNNING_IN_SHELL='true' B_RUNNING_IN_SHELL='true'
elif [ -n "$PPID" -a -f "/proc/$PPID/exe" ];then elif [[ -n $PPID && -f /proc/$PPID/exe ]];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 inxi from inside itself, as a script, the parent is konversation, not perl # when konversation starts inxi 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 )" ];then if [[ -z $( grep -i 'konversation' <<< $irc_client_path ) && -n $( grep -i 'perl' <<< $irc_client_path ) && -n $( pidof konversation ) ]];then
irc_client_path=$( which konversation ) irc_client_path=$( which konversation )
non_native_konvi='true' non_native_konvi='true'
fi fi
@ -591,7 +594,7 @@ 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' ];then if [[ $non_native_konvi == 'true' ]];then
KONVI=2 KONVI=2
else else
KONVI=1 KONVI=1
@ -675,8 +678,7 @@ get_start_source()
IRC_CLIENT="Weechat" IRC_CLIENT="Weechat"
;; ;;
*kvirc*) *kvirc*)
IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk ' IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk '{
{
for ( i=2; i<=NF; i++) { for ( i=2; i<=NF; i++) {
if (i==NF) { if (i==NF) {
print $i print $i
@ -713,7 +715,7 @@ get_start_source()
;; ;;
esac esac
done done
if [ -z "$IRC_CLIENT_VERSION" ];then if [[ -z $IRC_CLIENT_VERSION ]];then
IRC_CLIENT="Unknown Perl client" IRC_CLIENT="Unknown Perl client"
fi fi
;; ;;
@ -726,7 +728,7 @@ get_start_source()
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
;; ;;
esac esac
if [ "$SHOW_IRC" -lt 2 ];then if [[ $SHOW_IRC -lt 2 ]];then
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
fi fi
else else
@ -743,11 +745,6 @@ 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 "B_X_RUNNING" accordingly
if [ -n "$DISPLAY" ];then
B_X_RUNNING='true'
fi
# Fallback paths put into $extra_paths; This might, among others, help on gentoo. # Fallback paths put into $extra_paths; This might, among others, help on gentoo.
# Now, create a difference of $PATH and $extra_paths and add that to $PATH: # Now, create a difference of $PATH and $extra_paths and add that to $PATH:
IFS=":" IFS=":"
@ -756,11 +753,11 @@ set_calculated_variables()
b_path_found='false' b_path_found='false'
for sys_path in $PATH for sys_path in $PATH
do do
if [ "$path" == "$sys_path" ];then if [[ $path == $sys_path ]];then
b_path_found='true' b_path_found='true'
fi fi
done done
if [ "$b_path_found" == 'false' ];then if [[ $b_path_found == 'false' ]];then
added_path="$added_path:$path" added_path="$added_path:$path"
fi fi
done done
@ -793,7 +790,7 @@ get_audio_data()
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
# handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes.. # handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes..
if [ "${#A_AUDIO_DATA[@]}" -eq 0 ];then if [[ ${#A_AUDIO_DATA[@]} -eq 0 ]];then
A_AUDIO_DATA[0]='Failed to Detect Sound Card!' A_AUDIO_DATA[0]='Failed to Detect Sound Card!'
fi fi
} }
@ -805,7 +802,8 @@ get_cpu_core_count()
## Because of the upcoming release of cpus with core counts over 6, a count of cores is given after Deca (10) ## Because of the upcoming release of cpus with core counts over 6, a count of cores is given after Deca (10)
# count the number of processors given # count the number of processors given
local cpu_core_count=$(grep -ic "cpu cores" /proc/cpuinfo| cut -d':' -f2) local cpu_core_count=$(grep -ic "cpu cores" /proc/cpuinfo| cut -d':' -f2)
if [ "$cpu_core_count" -eq 0 ];then
if [[ $cpu_core_count -eq 0 ]];then
cpu_core_count=$(grep -ic "^processor" /proc/cpuinfo| cut -d':' -f2) cpu_core_count=$(grep -ic "^processor" /proc/cpuinfo| cut -d':' -f2)
fi fi
local cpu_alpha_count='' local cpu_alpha_count=''
@ -913,9 +911,9 @@ get_distro_data()
cd "$OLDPWD" cd "$OLDPWD"
shopt -u nullglob shopt -u nullglob
if [ "${#a_distro_glob[@]}" -eq 1 ];then if [[ ${#a_distro_glob[@]} -eq 1 ]];then
distro_file="${a_distro_glob}" distro_file="${a_distro_glob}"
elif [ "${#a_distro_glob[@]}" -gt 1 ];then elif [[ ${#a_distro_glob[@]} -gt 1 ]];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()
@ -929,11 +927,11 @@ get_distro_data()
fi fi
done done
fi fi
if [ -n "$distro_file" -a -s /etc/$distro_file -a " $DISTROS_EXCLUDE_LIST " != *" $distro_file "* ];then if [[ -n $distro_file && -s /etc/$distro_file && " $DISTROS_EXCLUDE_LIST " != *" $distro_file "* ]];then
distro=$( remove_erroneous_chars "/etc/$distro_file" ) distro=$( remove_erroneous_chars "/etc/$distro_file" )
# this is necessary because antiX doesn't use version/release in its distro id file name # this is necessary because antiX doesn't use version/release in its distro id file name
# so the glob tests fail. I expect those tests will need to be redone at some point to avoid this # so the glob tests fail. I expect those tests will need to be redone at some point to avoid this
elif [ -e /etc/antiX ];then elif [[ -e /etc/antiX ]];then
distro="$( egrep -oi 'antix.*\.iso' <<< $( remove_erroneous_chars '/etc/antiX' ) | sed 's/\.iso//' )" distro="$( egrep -oi 'antix.*\.iso' <<< $( remove_erroneous_chars '/etc/antiX' ) | sed 's/\.iso//' )"
else else
# Debian pure should fall through here # Debian pure should fall through here
@ -946,14 +944,17 @@ get_distro_data()
print print
}' "/etc/${distro_file}" ) }' "/etc/${distro_file}" )
fi fi
if [ "${#distro}" -gt 80 -a "$B_HANDLE_CORRUPT_DATA" != 'true' ];then if [[ ${#distro} -gt 80 && $B_HANDLE_CORRUPT_DATA != 'true' ]];then
distro="${RED}/etc/${distro_file} corrupted, use -C to override${NORMAL}" distro="${RED}/etc/${distro_file} corrupted, use -C to override${NORMAL}"
fi fi
## note: figure out a more readable way to achieve whatever is intended here ## ## note: would like to actually understand the method even if it's not used
: ${distro:=Unknown distro o_O} # : ${distro:=Unknown distro o_O}
if [[ -z $distro ]];then
distro='Unknown distro o_O'
fi
# this handles an arch bug where /etc/arch-release is empty and /etc/issue is corrupted # this handles an arch bug where /etc/arch-release is empty and /etc/issue is corrupted
if [ -n "$( grep -i 'arch linux' <<< $distro )" ];then if [[ -n $( grep -i 'arch linux' <<< $distro ) ]];then
distro='Arch Linux' distro='Arch Linux'
fi fi
echo "$distro" echo "$distro"
@ -972,7 +973,7 @@ get_graphics_card_data()
A_GFX_CARD_DATA[i]=$( sanitize_characters A_NORMAL_BANS "${A_GFX_CARD_DATA[i]}" ) A_GFX_CARD_DATA[i]=$( sanitize_characters A_NORMAL_BANS "${A_GFX_CARD_DATA[i]}" )
done done
# handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes.. # handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes..
if [ "${#A_GFX_CARD_DATA[@]}" -eq 0 ];then if [[ ${#A_GFX_CARD_DATA[@]} -eq 0 ]];then
A_GFX_CARD_DATA[0]='Failed to Detect Video Card!' A_GFX_CARD_DATA[0]='Failed to Detect Video Card!'
fi fi
@ -983,7 +984,7 @@ get_graphics_card_data()
## create array of glx data ## create array of glx data
get_graphics_glx_data() get_graphics_glx_data()
{ {
if [ "$B_X_RUNNING" == 'true' ];then if [[ $B_X_RUNNING == 'true' ]];then
IFS=$'\n' IFS=$'\n'
A_GLX_DATA=( $( glxinfo | gawk -F ': ' ' A_GLX_DATA=( $( glxinfo | gawk -F ': ' '
function join(arr, sep) { function join(arr, sep) {
@ -1028,7 +1029,7 @@ get_graphics_res_data()
{ {
local screen_resolution='' local screen_resolution=''
if [ "$B_X_RUNNING" == 'true' ];then if [[ $B_X_RUNNING == 'true' ]];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
screen_resolution=$( xrandr | gawk ' screen_resolution=$( xrandr | gawk '
@ -1043,7 +1044,7 @@ get_graphics_res_data()
} }
' ) ' )
if [ -z "$screen_resolution" ];then if [[ -z $screen_resolution ]];then
screen_resolution=$( xdpyinfo | gawk '/dimensions/ { print $2 }' ) screen_resolution=$( xdpyinfo | gawk '/dimensions/ { print $2 }' )
fi fi
else else
@ -1066,7 +1067,7 @@ get_graphics_x_data()
{ {
local x_vendor='' x_version='' local x_vendor='' x_version=''
if [ "$B_X_RUNNING" == 'true' ];then if [[ $B_X_RUNNING == 'true' ]];then
# X vendor and version detection. # X vendor and version detection.
x_vendor=$( xdpyinfo | gawk -F': +' ' x_vendor=$( xdpyinfo | gawk -F': +' '
BEGIN { IGNORECASE=1 } BEGIN { IGNORECASE=1 }
@ -1080,7 +1081,7 @@ get_graphics_x_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_version is empty, the release number is parsed instead) # A failover mechanism is in place. (if $x_version is empty, the release number is parsed instead)
x_version=$( xdpyinfo | awk '/version:/ { print $NF }' ) x_version=$( xdpyinfo | awk '/version:/ { print $NF }' )
if [ -z "$x_version" ];then if [[ -z $x_version ]];then
x_version=$(xdpyinfo | gawk -F': +' ' x_version=$(xdpyinfo | gawk -F': +' '
BEGIN { IGNORECASE=1 } BEGIN { IGNORECASE=1 }
/vendor release number/ { /vendor release number/ {
@ -1152,7 +1153,7 @@ get_hard_drive_data()
# this adds the (x) numbering in front of each disk found, and creates the full disk string # this adds the (x) numbering in front of each disk found, and creates the full disk string
hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}${a_total_hdd[i]}" hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}${a_total_hdd[i]}"
done done
if [ -z "$hdd_model" ];then if [[ -z $hdd_model ]];then
hdd_model=' Non Detected' hdd_model=' Non Detected'
fi fi
fi fi
@ -1172,7 +1173,7 @@ get_hard_drive_data()
hdd_capacity="${!i}" hdd_capacity="${!i}"
fi fi
done done
if [ "$hdd_capacity" -gt 0 ];then if [[ $hdd_capacity -gt 0 ]];then
hdd_used=$( df | gawk ' hdd_used=$( df | gawk '
p { p {
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) { if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
@ -1297,14 +1298,14 @@ calculate_multicore_data()
{ {
local string_number=$1 string_data='' local string_number=$1 string_data=''
if [ -n "$( egrep -i '( mb| kb)' <<< $1 )" ];then if [[ -n $( egrep -i '( mb| kb)' <<< $1 ) ]];then
string_data=" $( awk '{print $2}' <<< $1 )" # add a space for output string_data=" $( awk '{print $2}' <<< $1 )" # add a space for output
string_number=$( awk '{print $1}' <<< $1 ) string_number=$( awk '{print $1}' <<< $1 )
fi fi
# handle weird error cases where it's not a number # handle weird error cases where it's not a number
if [ -n "$( egrep '^[0-9\.,]+$' <<< $string_number )" ];then if [[ -n $( egrep '^[0-9\.,]+$' <<< $string_number ) ]];then
string_number=$( echo $string_number $2 | awk '{total = $1*$2; print total}' ) string_number=$( echo $string_number $2 | awk '{total = $1*$2; print total}' )
elif [ "$string_number" == '' ];then elif [[ $string_number == '' ]];then
string_number='Not Available' string_number='Not Available'
else else
string_number="Error data:$string_number " string_number="Error data:$string_number "
@ -1360,7 +1361,7 @@ process_cpu_flags()
' ) ' )
#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
cpu_flags="-" cpu_flags="-"
fi fi
echo "$cpu_flags" echo "$cpu_flags"
@ -1386,7 +1387,7 @@ print_audio_data()
card_one='Card ' card_one='Card '
fi fi
if [ -n "${a_audio_working[1]}" ];then if [[ -n ${a_audio_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[1]}" port_data=" ${C1}at port${C2} ${a_audio_working[1]}"
fi fi
audio_data="${C1}$card_one${C2}${a_audio_working[0]}$port_data" audio_data="${C1}$card_one${C2}${a_audio_working[0]}$port_data"
@ -1399,7 +1400,7 @@ print_audio_data()
a_audio_working=( ${A_AUDIO_DATA[i]} ) a_audio_working=( ${A_AUDIO_DATA[i]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
port_data='' port_data=''
if [ -n "${a_audio_working[1]}" ];then if [[ -n ${a_audio_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[1]}" port_data=" ${C1}at port${C2} ${a_audio_working[1]}"
fi fi
audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$port_data" audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$port_data"
@ -1435,11 +1436,11 @@ print_cpu_data()
fi fi
cpu_data=$( create_print_line "CPU:" "${C1}${cpu_core_count_string}${C2} ${a_cpu_working[0]}" ) cpu_data=$( create_print_line "CPU:" "${C1}${cpu_core_count_string}${C2} ${a_cpu_working[0]}" )
if [ "$VERBOSITY_LEVEL" -ge 3 ];then if [[ $VERBOSITY_LEVEL -ge 3 ]];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
# if [ "$cpu_vendor" != 'intel' ];then # if [[ $cpu_vendor != 'intel' ]];then
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$cpu_core_count" ) bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$cpu_core_count" )
# else # else
# bmip_data="${a_cpu_working[4]}" # bmip_data="${a_cpu_working[4]}"
@ -1447,20 +1448,20 @@ print_cpu_data()
bmip_data=" ${C1}bmips${C2} $bmip_data" bmip_data=" ${C1}bmips${C2} $bmip_data"
fi fi
## note: this handles how intel reports L2, total instead of per core like AMD does ## note: this handles how intel reports L2, total instead of per core like AMD does
if [ "$cpu_vendor" != 'intel' ];then if [[ $cpu_vendor != 'intel' ]];then
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_core_count" ) cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_core_count" )
else else
cpu_cache="${a_cpu_working[2]}" cpu_cache="${a_cpu_working[2]}"
fi fi
# only print shortened list # only print shortened list
if [ "$B_CPU_FLAGS_FULL" != 'true' ];then if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" ) cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" )
cpu_flags=" ${C1}flags${C2} ($cpu_flags)" cpu_flags=" ${C1}flags${C2} ($cpu_flags)"
fi fi
cpu_data="$cpu_data${C2} ${C1}cache${C2} $cpu_cache$cpu_flags$bmip_data${CN}" cpu_data="$cpu_data${C2} ${C1}cache${C2} $cpu_cache$cpu_flags$bmip_data${CN}"
fi fi
if [ "$VERBOSITY_LEVEL" -ge 5 -a "${#A_CPU_DATA[@]}" -gt 2 ];then if [[ $VERBOSITY_LEVEL -ge 5 && ${#A_CPU_DATA[@]} -gt 2 ]];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}"
@ -1469,23 +1470,23 @@ print_cpu_data()
cpu_data="$cpu_data $cpu_clock_speed" cpu_data="$cpu_data $cpu_clock_speed"
print_screen_output "$cpu_data" print_screen_output "$cpu_data"
if [ "$VERBOSITY_LEVEL" -ge 5 -a "${#A_CPU_DATA[@]}" -gt 2 ];then if [[ $VERBOSITY_LEVEL -ge 5 && ${#A_CPU_DATA[@]} -gt 2 ]];then
for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ )) for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))
do do
IFS="," IFS=","
a_cpu_working=(${A_CPU_DATA[i]}) a_cpu_working=(${A_CPU_DATA[i]})
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
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}"
if [ "$i" -gt 10 ];then if [[ $i -gt 10 ]];then
break break
fi fi
done done
if [ -n "$cpu_multi_clock_data" ];then if [[ -n $cpu_multi_clock_data ]];then
cpu_multi_clock_data=$( create_print_line " " "${C1}Clock Speeds:${C2}$cpu_multi_clock_data" ) cpu_multi_clock_data=$( create_print_line " " "${C1}Clock Speeds:${C2}$cpu_multi_clock_data" )
print_screen_output "$cpu_multi_clock_data" print_screen_output "$cpu_multi_clock_data"
fi fi
fi fi
if [ "$B_CPU_FLAGS_FULL" == 'true' ];then if [[ $B_CPU_FLAGS_FULL == 'true' ]];then
print_cpu_flags_full "${a_cpu_working[3]}" print_cpu_flags_full "${a_cpu_working[3]}"
fi fi
} }
@ -1498,24 +1499,24 @@ print_cpu_flags_full()
for flag in $cpu_flags_full for flag in $cpu_flags_full
do do
if [ "$i" -ge 36 ];then if [[ $i -ge 36 ]];then
cpu_flags_3="$cpu_flags_3$flag " cpu_flags_3="$cpu_flags_3$flag "
elif [ "$i" -ge 18 ];then elif [[ $i -ge 18 ]];then
cpu_flags_2="$cpu_flags_2$flag " cpu_flags_2="$cpu_flags_2$flag "
elif [ "$i" -ge 0 ];then elif [[ $i -ge 0 ]];then
cpu_flags_1="$cpu_flags_1$flag " cpu_flags_1="$cpu_flags_1$flag "
fi fi
((i++)) ((i++))
done done
if [ -n "$cpu_flags_1" ];then if [[ -n $cpu_flags_1 ]];then
flag_data=$( create_print_line " " "${C1}CPU Flags${C2} $cpu_flags_1" ) flag_data=$( create_print_line " " "${C1}CPU Flags${C2} $cpu_flags_1" )
print_screen_output "$flag_data" print_screen_output "$flag_data"
fi fi
if [ -n "$cpu_flags_2" ];then if [[ -n $cpu_flags_2 ]];then
flag_data=$( create_print_line " " "$cpu_flags_2" ) flag_data=$( create_print_line " " "$cpu_flags_2" )
print_screen_output "$flag_data" print_screen_output "$flag_data"
fi fi
if [ -n "$cpu_flags_3" ];then if [[ -n $cpu_flags_3 ]];then
flag_data=$( create_print_line " " "$cpu_flags_3" ) flag_data=$( create_print_line " " "$cpu_flags_3" )
print_screen_output "$flag_data" print_screen_output "$flag_data"
fi fi
@ -1550,21 +1551,21 @@ print_gfx_data()
fi fi
gfx_data=$( create_print_line "Graphics:" "${C1}$card_one${C2}${A_GFX_CARD_DATA[0]}${gfx_data}" ) gfx_data=$( create_print_line "Graphics:" "${C1}$card_one${C2}${A_GFX_CARD_DATA[0]}${gfx_data}" )
if [ "$B_X_RUNNING" == 'true' ];then if [[ $B_X_RUNNING == 'true' ]];then
gfx_data="${gfx_data} ${CN}| ${C1}$x_vendor${C2} $x_version ${CN}| ${C1}Res${C2} ${screen_resolution}" gfx_data="${gfx_data} ${CN}| ${C1}$x_vendor${C2} $x_version ${CN}| ${C1}Res${C2} ${screen_resolution}"
else else
gfx_data="${gfx_data} ${C1} tty resolution ${CN}(${C2} ${screen_resolution} ${CN})" gfx_data="${gfx_data} ${C1} tty resolution ${CN}(${C2} ${screen_resolution} ${CN})"
fi fi
print_screen_output "$gfx_data" print_screen_output "$gfx_data"
if [ -z "$glx_renderer" -o -z "$glx_version" ];then if [[ -z $glx_renderer || -z $glx_version ]];then
b_is_mesa='true' b_is_mesa='true'
fi fi
## note: if glx render or version have no content, then mesa is true ## note: if glx render or version have no content, then mesa is true
if [ "$B_X_RUNNING" == 'true' -a "$b_is_mesa" != 'true' ];then if [[ $B_X_RUNNING == 'true' && $b_is_mesa != 'true' ]];then
gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${glx_renderer} ${CN}| ${C1}GLX Version${C2} ${glx_version}${CN}" ) gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${glx_renderer} ${CN}| ${C1}GLX Version${C2} ${glx_version}${CN}" )
if [ "$B_HANDLE_CORRUPT_DATA" == 'true' ];then if [[ $B_HANDLE_CORRUPT_DATA == 'true' ]];then
gfx_data="${gfx_data} ${C1}Direct rendering${C2} ${glx_direct_render}${CN}" gfx_data="${gfx_data} ${C1}Direct rendering${C2} ${glx_direct_render}${CN}"
fi fi
print_screen_output "$gfx_data" print_screen_output "$gfx_data"
@ -1575,14 +1576,14 @@ print_hard_disk_data()
{ {
local hdd_data='' partition_data='' a_partition_working='' local hdd_data='' partition_data='' a_partition_working=''
if [ "$VERBOSITY_LEVEL" -ge 3 ];then if [[ $VERBOSITY_LEVEL -ge 3 ]];then
hdd_data=$( create_print_line "Disks:" "${C1}HDD${C2}${hdd_model} ${C1}Size${C2} ${hdd_capacity} (${hdd_used})${CN}" ) hdd_data=$( create_print_line "Disks:" "${C1}HDD${C2}${hdd_model} ${C1}Size${C2} ${hdd_capacity} (${hdd_used})${CN}" )
else else
hdd_data=$( create_print_line "Disks:" "${C1}HDD Size${C2} ${hdd_capacity} (${hdd_used})${CN}" ) hdd_data=$( create_print_line "Disks:" "${C1}HDD Size${C2} ${hdd_capacity} (${hdd_used})${CN}" )
fi fi
print_screen_output "$hdd_data" print_screen_output "$hdd_data"
if [ "$VERBOSITY_LEVEL" -ge 4 ];then if [[ $VERBOSITY_LEVEL -ge 4 ]];then
# set A_PARTITION_DATA # set A_PARTITION_DATA
get_partition_data get_partition_data
@ -1605,7 +1606,7 @@ print_intro_data()
local distro="$( get_distro_data )" local distro="$( get_distro_data )"
if [ "$B_SHOW_HOST" == 'true' ];then if [[ $B_SHOW_HOST == 'true' ]];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}" )
@ -1629,7 +1630,7 @@ print_networking_data()
card_one='Card ' card_one='Card '
fi fi
if [ -n "${a_network_working[1]}" ];then if [[ -n ${a_network_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_network_working[1]}" port_data=" ${C1}at port${C2} ${a_network_working[1]}"
fi fi
network_data="${C1}$card_one${C2}${a_network_working[0]}$port_data" network_data="${C1}$card_one${C2}${a_network_working[0]}$port_data"
@ -1642,7 +1643,7 @@ print_networking_data()
a_network_working=( ${A_NETWORK_DATA[i]} ) a_network_working=( ${A_NETWORK_DATA[i]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
port_data='' port_data=''
if [ -n "${a_network_working[1]}" ];then if [[ -n ${a_network_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_network_working[1]}" port_data=" ${C1}at port${C2} ${a_network_working[1]}"
fi fi
network_data="${C1}Card-$(( $i + 1 )) ${C2}${a_network_working[0]}$port_data" network_data="${C1}Card-$(( $i + 1 )) ${C2}${a_network_working[0]}$port_data"
@ -1662,7 +1663,7 @@ print_short_data()
local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]} local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]}
#set_color_scheme 12 #set_color_scheme 12
if [ "$B_RUNNING_IN_SHELL" == 'false' ];then if [[ $B_RUNNING_IN_SHELL == 'false' ]];then
for i in $C1 $C2 $CN for i in $C1 $C2 $CN
do do
case "$i" in case "$i" in
@ -1671,10 +1672,11 @@ print_short_data()
;; ;;
esac esac
done done
if [ "$b_background_black" == 'true' ];then if [[ $b_background_black == 'true' ]];then
for i in C1 C2 CN for i in C1 C2 CN
do do
if [[ "${!i}" = "$NORMAL" ]];then ## these need to be in quotes, don't know why
if [[ "${!i}" == "$NORMAL" ]];then
declare $i="${!i}15,1" declare $i="${!i}15,1"
else else
declare $i="${!i},1" declare $i="${!i},1"
@ -1685,11 +1687,11 @@ print_short_data()
fi fi
short_data="${C1}CPU${CN}[${C2}${cpu_core_count_string} ${cpu_model} ${C1}clocked at${C2} ${min_max_clock}${CN}] ${C1}Kernel${CN}[${C2}${current_kernel}${CN}] ${C1}Up${CN}[${C2}${FL2}${FL1}${up_time}${FL1}${CN}] ${C1}Mem${CN}[${C2}${FL2}${FL1}${memory}${FL1}${CN}] ${C1}HDD${CN}[${C2}${FL2}${FL1}${hdd_capacity}($hdd_used)${FL1}${CN}] ${C1}Procs${CN}[${C2}${FL2}${FL1}${processes}${FL1}${CN}]" short_data="${C1}CPU${CN}[${C2}${cpu_core_count_string} ${cpu_model} ${C1}clocked at${C2} ${min_max_clock}${CN}] ${C1}Kernel${CN}[${C2}${current_kernel}${CN}] ${C1}Up${CN}[${C2}${FL2}${FL1}${up_time}${FL1}${CN}] ${C1}Mem${CN}[${C2}${FL2}${FL1}${memory}${FL1}${CN}] ${C1}HDD${CN}[${C2}${FL2}${FL1}${hdd_capacity}($hdd_used)${FL1}${CN}] ${C1}Procs${CN}[${C2}${FL2}${FL1}${processes}${FL1}${CN}]"
if [ "$SHOW_IRC" -gt 0 ];then if [[ $SHOW_IRC -gt 0 ]];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 ];then if [[ $SCHEME -gt 0 ]];then
short_data="${short_data} $NORMAL" short_data="${short_data} $NORMAL"
fi fi
print_screen_output "$short_data" print_screen_output "$short_data"
@ -1706,16 +1708,16 @@ print_system_data()
system_data=$( create_print_line "Info:" "${C1}Processes${C2} ${processes} ${CN}| ${C1}Uptime${C2} ${up_time} ${CN}| ${C1}Memory${C2} ${memory}${CN}" ) system_data=$( create_print_line "Info:" "${C1}Processes${C2} ${processes} ${CN}| ${C1}Uptime${C2} ${up_time} ${CN}| ${C1}Memory${C2} ${memory}${CN}" )
# this only triggers if no X data is present # this only triggers if no X data is present
if [ "$B_X_RUNNING" != 'true' ];then if [[ $B_X_RUNNING != 'true' ]];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 ];then if [[ $SHOW_IRC -gt 0 ]];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 ];then if [[ $SCHEME -gt 0 ]];then
system_data="${system_data} ${NORMAL}" system_data="${system_data} ${NORMAL}"
fi fi
print_screen_output "$system_data" print_screen_output "$system_data"
@ -1760,10 +1762,10 @@ print_it_out()
print_intro_data print_intro_data
print_cpu_data print_cpu_data
print_gfx_data print_gfx_data
if [ "$VERBOSITY_LEVEL" -ge 6 ];then if [[ $VERBOSITY_LEVEL -ge 6 ]];then
print_audio_data print_audio_data
fi fi
if [ "$VERBOSITY_LEVEL" -ge 2 ];then if [[ $VERBOSITY_LEVEL -ge 2 ]];then
print_networking_data print_networking_data
fi fi
@ -1780,11 +1782,11 @@ set_calculated_variables
# Check for dependencies before running any commands in this script! So yes, here!! # Check for dependencies before running any commands in this script! So yes, here!!
check_script_depends check_script_depends
get_start_source get_start_client
# 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 ];then if [[ $KONVI -eq 1 ]];then
DCPORT="$1" DCPORT="$1"
DCSERVER="$2" DCSERVER="$2"
DCTARGET="$3" DCTARGET="$3"
@ -1810,7 +1812,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' ];then if [[ $COLOR_SCHEME_SET != 'true' ]];then
set_color_scheme "$DEFAULT_SCHEME" set_color_scheme "$DEFAULT_SCHEME"
fi fi
@ -1821,7 +1823,7 @@ script_debugger "B_ALL_UP=true : inxi up and running.."
print_it_out print_it_out
## last steps ## last steps
if [ "$B_RUNNING_IN_SHELL" == 'true' -a "$SCHEME" -gt 0 ];then if [[ $B_RUNNING_IN_SHELL == 'true' && $SCHEME -gt 0 ]];then
echo -n "" echo -n ""
fi fi