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
########################################################################
#### Script Name: inxi
#### version: 0.3.24
#### version: 0.3.25
#### Date: November 5 2008
########################################################################
#### 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'
# triggers various debugging and new option testing
B_TESTING_FLAG='false'
# Assume X not running until tests show it is
# Test for X running
B_X_RUNNING='false'
if [[ -n $DISPLAY ]];then
B_X_RUNNING='true'
fi
### Variable initializations: constants
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=0
### Reroute all error messages to the bitbucket (if not debugging)
if [ "$DEBUG" -eq 0 ]
if [[ $DEBUG -eq 0 ]]
then
exec 2>/dev/null
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]" )
### Source global config overrides
if [ -s /etc/$SCRIPT_NAME.conf ];then
if [[ -s /etc/$SCRIPT_NAME.conf ]];then
source /etc/$SCRIPT_NAME.conf
fi
# Source user config overrides
if [ -s $HOME/.$SCRIPT_NAME ];then
if [[ -s $HOME/.$SCRIPT_NAME ]];then
source $HOME/.$SCRIPT_NAME
fi
@ -234,11 +237,11 @@ script_debugger()
{
local a_debug_buffer=''
if [ "$B_ALL_UP" == 'true' ];then
if [ "$DEBUG" -eq 0 ];then
if [[ $B_ALL_UP == 'true' ]];then
if [[ $DEBUG -eq 0 ]];then
return
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++ ))
do
print_screen_output "${a_debug_buffer[DEBUG_BUFFER_INDEX]}"
@ -247,7 +250,7 @@ script_debugger()
fi
print_screen_output "$@"
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
fi
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
print_screen_output()
{
if [ "$DEBUG" -gt 5 ];then
if [ "$KONVI" -eq 1 ];then
if [[ $DEBUG -gt 5 ]];then
if [[ $KONVI -eq 1 ]];then
dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$@'"
else
echo "konvi='$KONVI' saying : '$@'"
@ -275,7 +278,7 @@ print_screen_output()
fi
#((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"
else
echo -ne "$1\n"
@ -328,15 +331,15 @@ check_script_depends()
{
local app_name='' app_data=''
if [ ! -d /proc/ ];then
if [[ ! -d /proc/ ]];then
error_handler 6
fi
if [ "$B_X_RUNNING" == 'true' ];then
if [[ $B_X_RUNNING == 'true' ]];then
for app_name in xrandr xdpyinfo glxinfo
do
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"
B_X_RUNNING='false'
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
do
app_data=$( type -p $app_name )
if [ -z "$app_data" ];then
if [[ -z $app_data ]];then
error_handler 5 "$app_name"
fi
done
@ -387,7 +390,7 @@ set_color_scheme()
set -- 1
fi
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 )
else
color_codes=( $IRC_COLORS )
@ -411,7 +414,7 @@ get_cmdline()
{
local i=0 ppid=$1
if [ ! -e /proc/$ppid/cmdline ];then
if [[ ! -e /proc/$ppid/cmdline ]];then
echo 0
return
fi
@ -424,7 +427,7 @@ get_cmdline()
A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ##
done </proc/$ppid/cmdline
##print_screen_output "\$i='$i'"
if [ "$i" -eq 0 ];then
if [[ $i -eq 0 ]];then
A_CMDL[0]=$(< /proc/$ppid/cmdline)
if [[ -n ${A_CMDL[0]} ]];then
i=1
@ -439,18 +442,18 @@ get_parameters()
{
local opt=''
if [ -z "$1" ];then
if [[ -z $1 ]];then
return 1
fi
while getopts c:CdDfhTUv:Vx opt
do
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'
## note: not sure about this, you'd think user values should be overridden, but
## we'll leave this for now
if [ -z "$COLOR_SCHEME" ];then
if [[ -z $COLOR_SCHEME ]];then
set_color_scheme "$OPTARG"
fi
else
@ -550,7 +553,7 @@ script_self_updater()
print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER"
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 "$?"
if [ "$?" -eq 0 ];then
if [[ $? -eq 0 ]];then
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."
exit 0
@ -566,7 +569,7 @@ script_self_updater()
#### -------------------------------------------------------------------
# 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=''
@ -574,11 +577,11 @@ get_start_source()
IRC_CLIENT="Shell"
unset IRC_CLIENT_VERSION
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 )
# 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
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 )
non_native_konvi='true'
fi
@ -591,7 +594,7 @@ get_start_source()
;;
*konversation*)
# 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
else
KONVI=1
@ -675,8 +678,7 @@ get_start_source()
IRC_CLIENT="Weechat"
;;
*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++) {
if (i==NF) {
print $i
@ -713,7 +715,7 @@ get_start_source()
;;
esac
done
if [ -z "$IRC_CLIENT_VERSION" ];then
if [[ -z $IRC_CLIENT_VERSION ]];then
IRC_CLIENT="Unknown Perl client"
fi
;;
@ -726,7 +728,7 @@ get_start_source()
unset IRC_CLIENT_VERSION
;;
esac
if [ "$SHOW_IRC" -lt 2 ];then
if [[ $SHOW_IRC -lt 2 ]];then
unset IRC_CLIENT_VERSION
fi
else
@ -743,11 +745,6 @@ set_calculated_variables()
# 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"
# 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.
# Now, create a difference of $PATH and $extra_paths and add that to $PATH:
IFS=":"
@ -756,11 +753,11 @@ set_calculated_variables()
b_path_found='false'
for sys_path in $PATH
do
if [ "$path" == "$sys_path" ];then
if [[ $path == $sys_path ]];then
b_path_found='true'
fi
done
if [ "$b_path_found" == 'false' ];then
if [[ $b_path_found == 'false' ]];then
added_path="$added_path:$path"
fi
done
@ -793,7 +790,7 @@ get_audio_data()
IFS="$ORIGINAL_IFS"
# 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!'
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)
# count the number of processors given
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)
fi
local cpu_alpha_count=''
@ -913,9 +911,9 @@ get_distro_data()
cd "$OLDPWD"
shopt -u nullglob
if [ "${#a_distro_glob[@]}" -eq 1 ];then
if [[ ${#a_distro_glob[@]} -eq 1 ]];then
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
do
# Only echo works with ${var[@]}, not print_screen_output() or script_debugger()
@ -929,11 +927,11 @@ get_distro_data()
fi
done
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" )
# 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
elif [ -e /etc/antiX ];then
elif [[ -e /etc/antiX ]];then
distro="$( egrep -oi 'antix.*\.iso' <<< $( remove_erroneous_chars '/etc/antiX' ) | sed 's/\.iso//' )"
else
# Debian pure should fall through here
@ -946,14 +944,17 @@ get_distro_data()
print
}' "/etc/${distro_file}" )
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}"
fi
## note: figure out a more readable way to achieve whatever is intended here ##
: ${distro:=Unknown distro o_O}
## note: would like to actually understand the method even if it's not used
# : ${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
if [ -n "$( grep -i 'arch linux' <<< $distro )" ];then
if [[ -n $( grep -i 'arch linux' <<< $distro ) ]];then
distro='Arch Linux'
fi
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]}" )
done
# 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!'
fi
@ -983,7 +984,7 @@ get_graphics_card_data()
## create array of glx data
get_graphics_glx_data()
{
if [ "$B_X_RUNNING" == 'true' ];then
if [[ $B_X_RUNNING == 'true' ]];then
IFS=$'\n'
A_GLX_DATA=( $( glxinfo | gawk -F ': ' '
function join(arr, sep) {
@ -1028,7 +1029,7 @@ get_graphics_res_data()
{
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
# 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0
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 }' )
fi
else
@ -1066,7 +1067,7 @@ get_graphics_x_data()
{
local x_vendor='' x_version=''
if [ "$B_X_RUNNING" == 'true' ];then
if [[ $B_X_RUNNING == 'true' ]];then
# X vendor and version detection.
x_vendor=$( xdpyinfo | gawk -F': +' '
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
# A failover mechanism is in place. (if $x_version is empty, the release number is parsed instead)
x_version=$( xdpyinfo | awk '/version:/ { print $NF }' )
if [ -z "$x_version" ];then
if [[ -z $x_version ]];then
x_version=$(xdpyinfo | gawk -F': +' '
BEGIN { IGNORECASE=1 }
/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
hdd_model="${hdd_model}${hdd_model+ ${C1}($(($i+1)))${C2}}${a_total_hdd[i]}"
done
if [ -z "$hdd_model" ];then
if [[ -z $hdd_model ]];then
hdd_model=' Non Detected'
fi
fi
@ -1172,7 +1173,7 @@ get_hard_drive_data()
hdd_capacity="${!i}"
fi
done
if [ "$hdd_capacity" -gt 0 ];then
if [[ $hdd_capacity -gt 0 ]];then
hdd_used=$( df | gawk '
p {
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
@ -1297,14 +1298,14 @@ calculate_multicore_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_number=$( awk '{print $1}' <<< $1 )
fi
# 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}' )
elif [ "$string_number" == '' ];then
elif [[ $string_number == '' ]];then
string_number='Not Available'
else
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' ' '))
if [ -z "$cpu_flags" ];then
if [[ -z $cpu_flags ]];then
cpu_flags="-"
fi
echo "$cpu_flags"
@ -1386,7 +1387,7 @@ print_audio_data()
card_one='Card '
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]}"
fi
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]} )
IFS="$ORIGINAL_IFS"
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]}"
fi
audio_data="${C1}Card-$(( $i + 1 )) ${C2}${a_audio_working[0]}$port_data"
@ -1435,11 +1436,11 @@ print_cpu_data()
fi
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.
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" )
# else
# bmip_data="${a_cpu_working[4]}"
@ -1447,20 +1448,20 @@ print_cpu_data()
bmip_data=" ${C1}bmips${C2} $bmip_data"
fi
## 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" )
else
cpu_cache="${a_cpu_working[2]}"
fi
# 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=" ${C1}flags${C2} ($cpu_flags)"
fi
cpu_data="$cpu_data${C2} ${C1}cache${C2} $cpu_cache$cpu_flags$bmip_data${CN}"
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
else
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"
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++ ))
do
IFS=","
a_cpu_working=(${A_CPU_DATA[i]})
IFS="$ORIGINAL_IFS"
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
fi
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" )
print_screen_output "$cpu_multi_clock_data"
fi
fi
if [ "$B_CPU_FLAGS_FULL" == 'true' ];then
if [[ $B_CPU_FLAGS_FULL == 'true' ]];then
print_cpu_flags_full "${a_cpu_working[3]}"
fi
}
@ -1498,24 +1499,24 @@ print_cpu_flags_full()
for flag in $cpu_flags_full
do
if [ "$i" -ge 36 ];then
if [[ $i -ge 36 ]];then
cpu_flags_3="$cpu_flags_3$flag "
elif [ "$i" -ge 18 ];then
elif [[ $i -ge 18 ]];then
cpu_flags_2="$cpu_flags_2$flag "
elif [ "$i" -ge 0 ];then
elif [[ $i -ge 0 ]];then
cpu_flags_1="$cpu_flags_1$flag "
fi
((i++))
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" )
print_screen_output "$flag_data"
fi
if [ -n "$cpu_flags_2" ];then
if [[ -n $cpu_flags_2 ]];then
flag_data=$( create_print_line " " "$cpu_flags_2" )
print_screen_output "$flag_data"
fi
if [ -n "$cpu_flags_3" ];then
if [[ -n $cpu_flags_3 ]];then
flag_data=$( create_print_line " " "$cpu_flags_3" )
print_screen_output "$flag_data"
fi
@ -1550,21 +1551,21 @@ print_gfx_data()
fi
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}"
else
gfx_data="${gfx_data} ${C1} tty resolution ${CN}(${C2} ${screen_resolution} ${CN})"
fi
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'
fi
## 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}" )
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}"
fi
print_screen_output "$gfx_data"
@ -1575,14 +1576,14 @@ print_hard_disk_data()
{
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}" )
else
hdd_data=$( create_print_line "Disks:" "${C1}HDD Size${C2} ${hdd_capacity} (${hdd_used})${CN}" )
fi
print_screen_output "$hdd_data"
if [ "$VERBOSITY_LEVEL" -ge 4 ];then
if [[ $VERBOSITY_LEVEL -ge 4 ]];then
# set A_PARTITION_DATA
get_partition_data
@ -1605,7 +1606,7 @@ print_intro_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}" )
else
intro_data=$( create_print_line "System:" "${C1}running${C2} ${CN}" )
@ -1629,7 +1630,7 @@ print_networking_data()
card_one='Card '
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]}"
fi
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]} )
IFS="$ORIGINAL_IFS"
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]}"
fi
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]}
#set_color_scheme 12
if [ "$B_RUNNING_IN_SHELL" == 'false' ];then
if [[ $B_RUNNING_IN_SHELL == 'false' ]];then
for i in $C1 $C2 $CN
do
case "$i" in
@ -1671,10 +1672,11 @@ print_short_data()
;;
esac
done
if [ "$b_background_black" == 'true' ];then
if [[ $b_background_black == 'true' ]];then
for i in C1 C2 CN
do
if [[ "${!i}" = "$NORMAL" ]];then
## these need to be in quotes, don't know why
if [[ "${!i}" == "$NORMAL" ]];then
declare $i="${!i}15,1"
else
declare $i="${!i},1"
@ -1685,11 +1687,11 @@ print_short_data()
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}]"
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}]"
fi
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"
fi
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}" )
# 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}"
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}"
fi
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}"
fi
print_screen_output "$system_data"
@ -1760,10 +1762,10 @@ print_it_out()
print_intro_data
print_cpu_data
print_gfx_data
if [ "$VERBOSITY_LEVEL" -ge 6 ];then
if [[ $VERBOSITY_LEVEL -ge 6 ]];then
print_audio_data
fi
if [ "$VERBOSITY_LEVEL" -ge 2 ];then
if [[ $VERBOSITY_LEVEL -ge 2 ]];then
print_networking_data
fi
@ -1780,11 +1782,11 @@ set_calculated_variables
# Check for dependencies before running any commands in this script! So yes, here!!
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
# 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"
DCSERVER="$2"
DCTARGET="$3"
@ -1810,7 +1812,7 @@ fi
get_parameters "$@"
# 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"
fi
@ -1821,7 +1823,7 @@ script_debugger "B_ALL_UP=true : inxi up and running.."
print_it_out
## 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 ""
fi