diff --git a/inxi b/inxi
index 1f3f008..df9b824 100755
--- a/inxi
+++ b/inxi
@@ -1,12 +1,12 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
-#### version: 0.3.28
-#### Date: November 6 2008
+#### version: 0.3.29
+#### Date: November 7 2008
########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif
#### As time permits functionality improvements and recoding will occur.
-####
+####
#### inxi, the universal, portable, system info script for irc.
#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
@@ -16,22 +16,22 @@
####
#### Current script home page: http://techpatterns.com/forums/about1131.html
#### Script svn: http://code.google.com/p/inxi
-####
+####
#### This program is free software; you can redistribute it and/or modify
#### it under the terms of the GNU General Public License as published by
#### the Free Software Foundation; either version 3 of the License, or
#### (at your option) any later version.
-####
+####
#### This program is distributed in the hope that it will be useful,
#### but WITHOUT ANY WARRANTY; without even the implied warranty of
#### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#### GNU General Public License for more details.
-####
+####
#### You should have received a copy of the GNU General Public License
#### along with this program. If not, see .
#### DEPENDENCIES
-#### bash >=2.05b(bash), df;readlink;stty;tr;uname;wc(coreutils),
+#### bash >=2.05b(bash), df;readlink;stty;tr;uname;wc(coreutils),
#### gawk(gawk), grep(grep), hostname(hostname), lspci(pciutils),
#### ps;uptime(procps), runlevel(sysvinit), glxinfo;xdpyinfo;xrandr(xbase-clients)
#### Also the proc filesystem should be present and mounted
@@ -74,7 +74,7 @@ B_EXTRA_DATA='false'
# override certain errors due to currupted data
B_HANDLE_CORRUPT_DATA='false'
# Running in a shell? Defaults to false, and is determined later.
-B_RUNNING_IN_SHELL='false'
+B_RUNNING_IN_SHELL='false'
# Set this to 'false' to avoid printing the hostname
B_SHOW_HOST='true'
# triggers various debugging and new option testing
@@ -82,7 +82,7 @@ B_TESTING_FLAG='false'
# Test for X running
B_X_RUNNING='false'
if [[ -n $DISPLAY ]];then
- B_X_RUNNING='true'
+ B_X_RUNNING='true'
fi
### Variable initializations: constants
@@ -94,26 +94,26 @@ DEBUG_BUFFER_INDEX=0
if [[ $DEBUG -eq 0 ]]
then
exec 2>/dev/null
-fi
+fi
#((DEBUG)) && exec 2>&1 # This is for debugging konversation
-# Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Set to any other valid scheme you like.
+# Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Set to any other valid scheme you like.
# Same as runtime parameter.
DEFAULT_SCHEME=2
# Default indentation level
-INDENT=10
+INDENT=10
# default to false, no konversation found, 1 is /cmd inxi start, 2 is native konvi script mode
-KONVI=0
+KONVI=0
# NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
# This is a variable that controls how many parameters inxi will parse in a /proc//cmdline file before stopping.
-PARAMETER_LIMIT=30
+PARAMETER_LIMIT=30
SCHEME=0 # set default scheme
# SHOW_IRC=1 to avoid showing the irc client version number, or SHOW_IRC=0 to disable client information completely.
-SHOW_IRC=2
+SHOW_IRC=2
# Verbosity level defaults to 0, this can also be set with -v0, -v2, -v3, etc as a parameter.
-VERBOSITY_LEVEL=0
+VERBOSITY_LEVEL=0
# Supported number of verbosity levels, including 0
-VERBOSITY_LEVELS=6
+VERBOSITY_LEVELS=6
# Clear nullglob, because it creates unpredictable situations with IFS=$'\n' ARR=($VAR) IFS="$ORIGINAL_IFS"
# type constructs. Stuff like [rev a1] is now seen as a glob expansion pattern, and fails, and
@@ -121,9 +121,9 @@ VERBOSITY_LEVELS=6
shopt -u nullglob
## info on bash built in: $IFS - http://tldp.org/LDP/abs/html/internalvariables.html
# Backup the current Internal Field Separator
-ORIGINAL_IFS="$IFS"
+ORIGINAL_IFS="$IFS"
# These two determine separators in single line output, to force irc clients not to break off sections
-FL1='-'
+FL1='-'
FL2=''
### Script names/paths
@@ -134,12 +134,12 @@ KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-conf
### Script Localization
# Make sure every program speaks English.
-LC_ALL="C"
-export LC_ALL
+LC_ALL="C"
+export LC_ALL
### Output Colors
# A more elegant way to have a scheme that doesn't print color codes (neither ANSI nor mIRC) at all. See below.
-unset EMPTY
+unset EMPTY
# DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW
ANSI_COLORS="[1;30m [0;30m [1;31m [0;31m [1;32m [0;32m [1;33m [0;33m"
IRC_COLORS=" \x0314 \x0301 \x0304 \x0305 \x0309 \x0303 \x0308 \x0307"
@@ -156,7 +156,7 @@ C2=''
CN=''
### Distro Data
-# In cases of derived distros where the version file of the base distro can also be found under /etc,
+# In cases of derived distros where the version file of the base distro can also be found under /etc,
# the derived distro's version file should go first. (Such as with Sabayon / Gentoo)
DISTROS_DERIVED="antix-version kanotix-version knoppix-version redhat-release sabayon-release sidux-version turbolinux-release zenwalk-version"
# debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
@@ -176,16 +176,16 @@ BAN_LIST_CPU=''
### Source global config overrides
if [[ -s /etc/$SCRIPT_NAME.conf ]];then
- source /etc/$SCRIPT_NAME.conf
+ source /etc/$SCRIPT_NAME.conf
fi
# Source user config overrides
if [[ -s $HOME/.$SCRIPT_NAME ]];then
source $HOME/.$SCRIPT_NAME
fi
-# WARNING: In the main part below (search for 'KONVI')
+# WARNING: In the main part below (search for 'KONVI')
# there's a check for Konversation-specific config files.
-# Any one of these can override the above if inxi is run
+# Any one of these can override the above if inxi is run
# from Konversation!
########################################################################
@@ -198,28 +198,28 @@ fi
# Error handling
# args: $1 - error number; $2 - optional, extra information
-error_handler()
+error_handler()
{
local error_message=''
-
+
# assemble the error message
case $1 in
2) error_message="large flood danger, debug buffer full!"
;;
- 3) error_message="unsupported color scheme number: $2"
+ 3) error_message="unsupported color scheme number: $2"
;;
- 4) error_message="unsupported verbosity level: $2"
+ 4) error_message="unsupported verbosity level: $2"
;;
- 5) error_message="dependency not met: $2 not found in path"
+ 5) error_message="dependency not met: $2 not found in path"
;;
- 6) error_message="/proc not found! Quitting..."
+ 6) error_message="/proc not found! Quitting..."
;;
- 7) error_message="unknown parameter: $2"
+ 7) error_message="unknown parameter: $2"
;;
8) error_message="the self-updater failed, wget exited with error: $2.\nYou probably need to be root.\nHint, to make for easy updates without being root, do: chown $SCRIPT_NAME"
;;
- *) error_message="error unknown: $@"
- set -- 99
+ *) error_message="error unknown: $@"
+ set -- 99
;;
esac
# then print it and exit
@@ -227,10 +227,10 @@ error_handler()
exit $1
}
-script_debugger()
+script_debugger()
{
local a_debug_buffer=''
-
+
if [[ $B_ALL_UP == 'true' ]];then
if [[ $DEBUG -eq 0 ]];then
return
@@ -259,7 +259,7 @@ script_debugger()
# note, this is a huge bug trap, for now we're not using this at all except to
# output basic stuff. At some point in the future we'll debug the dcop stuff,
# 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 [[ $KONVI -eq 1 ]];then
@@ -288,21 +288,21 @@ create_print_line()
printf "${C1}%-${INDENT}s${C2} %s" "$1" "$2"
}
-# this removes newline and pipes.
+# this removes newline and pipes.
# args: $1 - string to clean
remove_erroneous_chars()
{
## RS is input record separator
## gsub is substitute;
gawk '
- BEGIN { RS="" } {
+ BEGIN { RS="" } {
gsub(/\n$/,"") ## (newline; end of string) with (nothing)
gsub(/\n/," "); ## (newline) with (space)
gsub(/^ *| *$/, "") ## (pipe char) with (nothing)
gsub(/ +/, " ") ## ( +) with (space)
gsub(/ [ ]+/, " ") ## ([ ]+) with (space)
gsub(/^ +| +$/, "") ## (pipe char) with (nothing)
- printf $0
+ printf $0
}' "$1" ## prints (returns) cleaned input
}
@@ -311,9 +311,9 @@ remove_erroneous_chars()
## in bash. For now I'll leave this here because there's still some interesting stuff to get re methods
# Enforce boilerplate and buzzword filters
# args: $1 - BAN_LIST_NORMAL/BAN_LIST_CPU; $2 - string to sanitize
-sanitize_characters()
+sanitize_characters()
{
- # Cannot use strong quotes to unquote a string with pipes in it!
+ # Cannot use strong quotes to unquote a string with pipes in it!
# bash will interpret the |'s as usual and try to run a subshell!
# Using weak quotes instead, or use '"..."'
echo "$2" | gawk "
@@ -329,11 +329,11 @@ sanitize_characters()
#### basic tests
#### -------------------------------------------------------------------
-# Determine if any of the absolutely necessary tools are absent
-check_script_depends()
+# Determine if any of the absolutely necessary tools are absent
+check_script_depends()
{
local app_name='' app_data=''
-
+
if [[ ! -d /proc/ ]];then
error_handler 6
fi
@@ -349,7 +349,7 @@ check_script_depends()
fi
done
fi
-
+
app_name=''
# bc removed from deps for now
for app_name in df free gawk grep hostname lspci ps readlink runlevel tr uname uptime wc
@@ -363,10 +363,10 @@ check_script_depends()
# Filter boilerplate & buzzwords.
# args: $1 - quoted: "$@" array of ban terms
-make_ban_lists()
+make_ban_lists()
{
local ban_list=''
- # Iterate over $@
+ # Iterate over $@
## note: this is a weird, non-intuitive method, needs some documentation or rewriting
## if you declare ban_string it stops working, have to read up on this
for ban_string
@@ -375,26 +375,26 @@ make_ban_lists()
if [[ ${ban_string:0:1} = $'\2' ]];then
ban_list="${ban_list}${ban_list+|}${ban_string:1:${#ban_string}-1}"
else
- # Automatically escapes [ ] ( ) . and +
- ban_list="${ban_list}${ban_list+|}$( echo "$ban_string" | gawk '{
+ # Automatically escapes [ ] ( ) . and +
+ ban_list="${ban_list}${ban_list+|}$( echo "$ban_string" | gawk '{
gsub(/([\[\]+().])/,"\\\\&")
- print
+ print
}' )"
fi
done
-
+
echo "$ban_list"
}
# make_ban_lists "${A_CPU_BANS[@]}";exit
-# Set the colorscheme
+# Set the colorscheme
# args: $1 = |<"none">
-set_color_scheme()
+set_color_scheme()
{
local i='' script_colors='' color_codes=''
-
+
if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]];then
- set -- 1
+ set -- 1
fi
SCHEME="$1" # Set a global variable to allow checking for chosen scheme later
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
@@ -417,10 +417,10 @@ set_color_scheme()
# Parse the null separated commandline under /proc//cmdline
# args: $1 - $PPID
-get_cmdline()
+get_cmdline()
{
local i=0 ppid=$1
-
+
if [[ ! -e /proc/$ppid/cmdline ]];then
echo 0
return
@@ -430,7 +430,7 @@ get_cmdline()
unset A_CMDL
## note: need to figure this one out, and ideally clean it up and make it readable
while read -d $'\0' L && [ "$i" -lt 32 ]
- do
+ do
A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ##
done /dev/null;then
IRC_CLIENT="Shell"
unset IRC_CLIENT_VERSION
@@ -593,7 +593,7 @@ get_start_client()
non_native_konvi='true'
fi
irc_client_path_lower=$( tr '[:upper:]' '[:lower:]' <<< $irc_client_path )
-
+
case $irc_client_path_lower in
*irssi-text*|*irssi*)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk 'NR == 1 { print $2 }' )"
@@ -607,21 +607,21 @@ get_start_client()
KONVI=1
fi
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
- /Konversation:/ {
+ /Konversation:/ {
for ( i=2; i<=NF; i++ ) {
if (i == NF) {
- print $i
- }
- else {
- printf $i" "
- }
- }
- exit
+ print $i
+ }
+ else {
+ printf $i" "
+ }
+ }
+ exit
}' )"
T=($IRC_CLIENT_VERSION)
if [[ ${T[0]} == *+* ]];then
- # < Sho_> locsmif: The version numbers of SVN versions look like this:
- # "+ # locsmif: The version numbers of SVN versions look like this:
+ # "+ #&1 | gawk '{
for ( i=2; i<=NF; i++) {
if (i==NF) {
print $i
}
- else {
+ else {
printf $i" "
}
- }exit
+ }exit
}' )"
IRC_CLIENT="KVIrc"
;;
@@ -702,7 +702,7 @@ get_start_client()
IRC_CLIENT_VERSION=" $( kopete -v | gawk '
/Kopete:/ {
print $2
- exit
+ exit
}' )"
IRC_CLIENT="Kopete"
;;
@@ -712,7 +712,7 @@ get_start_client()
for (( i=0; i <= $CMDL_MAX; i++ ))
do
case ${A_CMDL[i]} in
- *dsirc*)
+ *dsirc*)
IRC_CLIENT="KSirc"
# Dynamic runpath detection is too complex with KSirc, because KSirc is started from
# kdeinit. /proc//exe is a link to /usr/bin/kdeinit
@@ -723,14 +723,14 @@ get_start_client()
# KSirc was run by browsing up the process tree in /proc. That alone is straightjacket material.
# (KSirc sucks anyway ;)
IRC_CLIENT_VERSION=" $( ksirc -v | gawk '
- /KSirc:/ {
+ /KSirc:/ {
print $2
- exit
+ exit
}' )"
break
;;
esac
- done
+ done
if [[ -z $IRC_CLIENT_VERSION ]];then
IRC_CLIENT="Unknown Perl client"
fi
@@ -759,16 +759,16 @@ set_calculated_variables()
{
local path='' sys_path='' added_path='' b_path_found=''
# 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"
+
# 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=":"
for path in $extra_paths
- do
+ do
b_path_found='false'
for sys_path in $PATH
- do
+ do
if [[ $path == $sys_path ]];then
b_path_found='true'
fi
@@ -779,9 +779,9 @@ set_calculated_variables()
done
IFS="$ORIGINAL_IFS"
PATH="${PATH}${added_path}"
- ##echo "PATH='$PATH'"
- ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
-
+ ##echo "PATH='$PATH'"
+ ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
+
# Do this after sourcing of config overrides so user can customize banwords
BAN_LIST_NORMAL=$( make_ban_lists "${A_NORMAL_BANS[@]}" ) # Contrary to my previous belief, "${ARR[@]}" passes a quoted list, not one string
BAN_LIST_CPU=$( make_ban_lists "${A_CPU_BANS[@]}" )
@@ -798,13 +798,13 @@ get_audio_data()
IFS=$'\n'
A_AUDIO_DATA=( $( echo "$lspci_data" | gawk -F': ' '
- { IGNORECASE=1 }
- /multimedia audio controller|audio device/ {
+ { IGNORECASE=1 }
+ /multimedia audio controller|audio device/ {
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/,/," ",$NF)
gsub(/^ +| +$/,"",$NF)
gsub(/ [ \t]+/," ",$NF)
- print $NF
+ print $NF
}' ) )
IFS="$ORIGINAL_IFS"
@@ -820,19 +820,19 @@ 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)
-
+ local cpu_core_count=$(grep -ic "cpu cores" /proc/cpuinfo| cut -d':' -f2)
+
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
local cpu_alpha_count=''
if [[ $cpu_core_count -lt 2 ]]; then
cpu_core_count=1
fi
-
+
# match the numberic value to an alpha value
- case $cpu_core_count in
+ case $cpu_core_count in
1) cpu_alpha_count='Single';;
2) cpu_alpha_count='Dual';;
3) cpu_alpha_count='Triple';;
@@ -856,12 +856,12 @@ get_cpu_data()
IFS=$'\n'
A_CPU_DATA=($(gawk -F': ' '
- { IGNORECASE=1 }
+ { IGNORECASE=1 }
# TAKE NOTE: \t+ will work for /proc/cpuinfo, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
# Therefore PATCH to use [ \t]+ when TESTING!
/^processor\t+:/ { nr = $NF }
-
- /^model name|^cpu\t+:/ {
+
+ /^model name|^cpu\t+:/ {
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
gsub(/,/, " ", $NF)
@@ -869,53 +869,53 @@ get_cpu_data()
gsub(/ [ \t]+/, " ", $NF)
cpu[nr, "model"] = $NF
}
-
+
/^cpu MHz|^clock\t+:/ {
- if (!min) {
+ if (!min) {
min = $NF
- }
- else {
- if ($NF < min) {
- min = $NF
- }
}
-
- if ($NF > max) {
- max = $NF
+ else {
+ if ($NF < min) {
+ min = $NF
+ }
+ }
+
+ if ($NF > max) {
+ max = $NF
}
gsub(/MHZ/,"",$NF) ## clears out for cell cpu
gsub(/.00[0]+$/,".00",$NF) ## clears out excessive zeros
cpu[nr, "speed"] = $NF
}
-
+
/^cache size/ { cpu[nr, "cache"] = $NF }
-
+
/^flags/ { cpu[nr, "flags"] = $NF }
-
+
/^bogomips/ { cpu[nr, "bogomips"] = $NF }
-
+
/vendor_id/ {
gsub(/genuine|authentic/,"",$NF)
cpu[nr, "vendor"] = $NF
}
-
+
END {
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
for ( i = 0; i <= nr; i++ ) {
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"]
}
- if (!min) {
+ if (!min) {
print "not found"
- exit
+ exit
}
- if (min != max) {
- printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
+ if (min != max) {
+ printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
}
- else {
- printf("%s %s\n", max, "Mhz")
+ else {
+ printf("%s %s\n", max, "Mhz")
}
}' /proc/cpuinfo))
-
+
IFS="$ORIGINAL_IFS"
}
@@ -923,7 +923,7 @@ get_cpu_data()
get_distro_data()
{
local i='' distro='' distro_file='' a_distro_glob=''
-
+
shopt -s nullglob
cd /etc
a_distro_glob=(*[-_]{release,version})
@@ -956,12 +956,12 @@ get_distro_data()
# Debian pure should fall through here
distro_file="issue"
distro=$( gawk '
- BEGIN { RS="" } {
+ BEGIN { RS="" } {
gsub(/\\[a-z]/, "")
gsub(/,/, " ")
gsub(/^ +| +$/, "")
gsub(/ [ \t]+/, " ")
- print
+ print
}' "/etc/${distro_file}" )
fi
if [[ ${#distro} -gt 80 && $B_HANDLE_CORRUPT_DATA != 'true' ]];then
@@ -972,7 +972,7 @@ get_distro_data()
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
distro='Arch Linux'
@@ -984,7 +984,7 @@ get_distro_data()
get_graphics_card_data()
{
local i=''
-
+
IFS=$'\n'
A_GFX_CARD_DATA=( $( echo "$lspci_data" | gawk -F': ' '
{ IGNORECASE=1 }
@@ -993,7 +993,7 @@ get_graphics_card_data()
gsub(/,/, " ", $NF)
gsub(/^ +| +$/, "", $NF)
gsub(/ [ \t]+/, " ", $NF)
- print $NF
+ print $NF
}' ) )
IFS="$ORIGINAL_IFS"
# for (( i=0; i < ${#A_GFX_CARD_DATA[@]}; i++ ))
@@ -1004,7 +1004,7 @@ get_graphics_card_data()
if [[ ${#A_GFX_CARD_DATA[@]} -eq 0 ]];then
A_GFX_CARD_DATA[0]='Failed to Detect Video Card!'
fi
-
+
# GFXMEM is UNUSED at the moment, because it shows AGP aperture size, which is not necessarily equal to GFX memory..
# GFXMEM="size=[$(echo "$lspci_data" | gawk '/VGA/{while (!/^$/) {getline;if (/size=[0-9][0-9]*M/) {size2=gensub(/.*\[size=([0-9]+)M\].*/,"\\1","g",$0);if (size 0 { print(gensub(/(.*)_agp.*/,"\\1","g",$1)) }' /proc/modules )
}
@@ -1090,12 +1090,12 @@ get_graphics_agp_data()
get_graphics_x_data()
{
local x_vendor='' x_version=''
-
+
if [[ $B_X_RUNNING == 'true' ]];then
# X vendor and version detection.
x_vendor=$( xdpyinfo | gawk -F': +' '
- BEGIN { IGNORECASE=1 }
- /vendor string/ {
+ BEGIN { IGNORECASE=1 }
+ /vendor string/ {
gsub(/the|inc|foundation|project|corporation/, "", $2)
gsub(/,/, " ", $2)
gsub(/^ +| +$/, "", $2)
@@ -1103,14 +1103,14 @@ get_graphics_x_data()
print $2
}' )
- # new method added since radeon and X.org and the disappearance of version : ...etc
+ # new method added since radeon and X.org and the disappearance of version : ...etc
# 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
x_version=$(xdpyinfo | gawk -F': +' '
- BEGIN { IGNORECASE=1 }
- /vendor release number/ {
+ BEGIN { IGNORECASE=1 }
+ /vendor release number/ {
gsub(/0+$/, "", $2)
gsub(/0+/, ".", $2)
print $2
@@ -1118,7 +1118,7 @@ get_graphics_x_data()
fi
A_X_DATA[0]="$x_vendor"
A_X_DATA[1]="$x_version"
-
+
#X -version 2>&1 | gawk '/^X Window System Version/ { print $5 }'
#This method could be used in the future to detect X when X is not running,
#however currently inxi ignores X checks when X is not found.
@@ -1130,10 +1130,10 @@ get_hard_drive_data()
{
local disk='' i='' hdd_cap2='' hdd_cap1='' disk_capacity='' a_total_hdd=''
local hdd_model='' hdd_capacity='' hdd_used=''
-
+
i=1
for disk in /proc/ide/ide*/hd*
- do
+ do
if [[ -e $disk/media && $( remove_erroneous_chars $disk/media ) = disk ]];then
# BUGFIX: Ran into a debian sarge kernel that did not have the "capacity" file in the hd* directories
# also, for PCI ata controller card, no capacity is listed
@@ -1147,7 +1147,7 @@ get_hard_drive_data()
((i++))
fi
done
-
+
if [[ -e /proc/scsi/scsi ]];then
# Silly sata detection, will also pick up usb sticks. This will be redone.
IFS=$'\n'
@@ -1174,7 +1174,7 @@ get_hard_drive_data()
}
}' /proc/scsi/scsi))
IFS="$ORIGINAL_IFS"
-
+
## note: the output part of this should be in the print hdd data function, not here
for (( i=0; i < ${#a_total_hdd[@]}; i++ ))
do
@@ -1185,14 +1185,14 @@ get_hard_drive_data()
hdd_model=' Non Detected'
fi
fi
-
+
##print_screen_output "$hdd_model" ; exit
if ((disk_capacity));then
hdd_cap1="$((disk_capacity/2))"
fi
# See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below
hdd_cap2=$( gawk '$1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} END {printf("%d\n",size)}' /proc/partitions )
-
+
##print_screen_output "hdd_cap1=\"$hdd_cap1\" hdd_cap2=\"$hdd_cap2"" ; exit
hdd_capacity=0
for i in ${!hdd_cap*}
@@ -1200,28 +1200,28 @@ get_hard_drive_data()
if [[ ${!i} -gt $hdd_capacity ]];then
hdd_capacity="${!i}"
fi
- done
+ done
if [[ $hdd_capacity -gt 0 ]];then
hdd_used=$( df | gawk '
- p {
- if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
- if (NF == 1) {
- getline
- if (NF == 5) {
- c += $2
- }
- else {
- next
+ p {
+ if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
+ if (NF == 1) {
+ getline
+ if (NF == 5) {
+ c += $2
}
- }
- else if (NF == 6) {
- c += $3
- }
- }
- }
- /^Filesystem/ { p++ }
- END {
- print c
+ else {
+ next
+ }
+ }
+ else if (NF == 6) {
+ c += $3
+ }
+ }
+ }
+ /^Filesystem/ { p++ }
+ END {
+ print c
}' )
hdd_used="$((hdd_used*100/hdd_capacity))% used"
hdd_capacity="$(($hdd_capacity*1024/1000**3))GB"
@@ -1236,9 +1236,9 @@ get_hard_drive_data()
get_lspci_data()
{
- echo "$( lspci -v | awk '{
+ echo "$( lspci -v | awk '{
gsub(/\(prog-if[^)]*\)/,"")
- print
+ print
}' )"
}
@@ -1246,7 +1246,7 @@ get_lspci_data()
get_memory_data()
{
local memory=''
-
+
memory=$( gawk '
/^MemTotal:/ { tot = $2 }
/^(MemFree|Buffers|Cached):/ { notused+=$2 }
@@ -1254,7 +1254,7 @@ get_memory_data()
used = tot-notused
printf("%.1f/%.1fMB\n", used/1024, tot/1024)
}' /proc/meminfo )
-
+
echo "$memory"
}
@@ -1273,7 +1273,7 @@ get_networking_data()
gsub(/,/, " ", nic)
gsub(/^ +| +$/, "", nic)
gsub(/ [ \t]+/, " ", nic)
-
+
eth[nic]++
while (getline && !/^$/) {
if (/I\/O/) {
@@ -1281,7 +1281,7 @@ get_networking_data()
}
}
}
-
+
END {
j=0
for (i in eth) {
@@ -1311,19 +1311,23 @@ get_partition_data()
{
IFS=$'\n'
# sample line: /dev/sda2 ext3 15G 8.9G 4.9G 65% /home
- # $7 = partition name; $3 = partition size; $4 = used, in gB; $6 = percent used
- A_PARTITION_DATA=( $( df -h -T | egrep '(/|/boot|/var|/home)$' | awk '{print $7 "," $3 "," $4 "," $6 }' ) )
+ # $NF = partition name; $(NF - 4) = partition size; $(NF - 3) = used, in gB; $(NF - 1) = percent used
+ ## note: by subtracting from the last field number NF, we avoid a subtle issue with df output, where if
+ ## the first field is too long, it will occupy its own line, this way we are getting only the needed data
+ A_PARTITION_DATA=( $( df -h -T | awk '
+ /\/$|\/boot$|\/var$|\/home$/ {
+ print $NF "," $(NF - 4) "," $(NF - 3) "," $(NF - 1)
+ }' ) )
IFS="$ORIGINAL_IFS"
}
-
## return uptime string
get_uptime()
{
## note: removing gsub(/ /,"",a); to get get space back in there, goes right before print a
- echo $( uptime | gawk '{
+ echo $( uptime | gawk '{
a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0)
- print a
+ print a
}' )
}
@@ -1336,7 +1340,7 @@ get_uptime()
calculate_multicore_data()
{
local string_number=$1 string_data=''
-
+
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 )
@@ -1357,7 +1361,7 @@ calculate_multicore_data()
process_cpu_flags()
{
local cpu_flags="$1"
-
+
# nx = AMD stack protection extensions
# lm = Intel 64bit extensions
# sse, sse2, pni = sse1,2,3 gfx extensions
@@ -1374,18 +1378,18 @@ process_cpu_flags()
sses[3] = "sse3"
}
/^(nx|lm|svm|vmx)$/ {
- if (s) {
- s = s " " $0
+ if (s) {
+ s = s " " $0
}
- else {
- s = $0
+ else {
+ s = $0
}
}
/^(sse2?|pni)$/ {
if (ssel[$0] > sse) {
sse = ssel[$0]
}
- }
+ }
END {
if (sse) {
if (s) {
@@ -1397,7 +1401,7 @@ process_cpu_flags()
}
print s
}' )
-
+
#grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' '))
if [[ -z $cpu_flags ]];then
cpu_flags="-"
@@ -1418,13 +1422,13 @@ print_audio_data()
IFS=","
a_audio_working=(${A_AUDIO_DATA[0]})
- IFS="$ORIGINAL_IFS"
-
+ IFS="$ORIGINAL_IFS"
+
if [[ -n ${A_AUDIO_DATA[@]} ]];then
if [[ ${#A_AUDIO_DATA[@]} -le 1 ]];then
card_one='Card '
fi
-
+
if [[ -n ${a_audio_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[1]}"
fi
@@ -1436,7 +1440,7 @@ print_audio_data()
do
IFS=","
a_audio_working=( ${A_AUDIO_DATA[i]} )
- IFS="$ORIGINAL_IFS"
+ IFS="$ORIGINAL_IFS"
port_data=''
if [[ -n ${a_audio_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_audio_working[1]}"
@@ -1454,17 +1458,17 @@ print_cpu_data()
local bmip_data='' cpu_cache='' cpu_vendor='' cpu_flags=''
##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\""
- # Array A_CPU_DATA always has one element: max clockfreq found.
+ # Array A_CPU_DATA always has one element: max clockfreq found.
# that's why its count is one more than you'd think from cores/cpus alone
# weird hack, probably should be changed
cpu_vendor=$( tr '[A-Z]' '[a-z]' <<< ${a_cpu_working[5]} )
# Strange (and also some expected) behavior encountered.
- # If print_screen_output() uses $1 as the parameter to output to the screen,
+ # If print_screen_output() uses $1 as the parameter to output to the screen,
# then passing " ${ARR[@]} "
- # will output only and the first element of ARR. That "@" splits in elements and "*" _doesn't_,
+ # will output only and the first element of ARR. That "@" splits in elements and "*" _doesn't_,
# is to be expected.
- # However, that text2 is consecutively truncated is somewhat strange, so take note.
+ # However, that text2 is consecutively truncated is somewhat strange, so take note.
# This has been confirmed by #bash on freenode.
# The above mentioned only emerges when using the debugging markers below
## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
@@ -1477,7 +1481,7 @@ print_cpu_data()
if [[ $VERBOSITY_LEVEL -ge 3 ]];then
# update for multicore, bogomips x core count.
if [[ $B_EXTRA_DATA == 'true' ]];then
-
+
# if [[ $cpu_vendor != 'intel' ]];then
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$cpu_core_count" )
# else
@@ -1491,7 +1495,7 @@ print_cpu_data()
else
cpu_cache="${a_cpu_working[2]}"
fi
- # only print shortened list
+ # only print shortened list
if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" )
cpu_flags=" ${C1}flags${C2} ($cpu_flags)"
@@ -1504,7 +1508,7 @@ print_cpu_data()
else
cpu_data="$cpu_data ${C1}clocked at${C2} ${a_cpu_working[1]} MHz${CN}"
fi
-
+
cpu_data="$cpu_data $cpu_clock_speed"
print_screen_output "$cpu_data"
@@ -1534,7 +1538,7 @@ print_cpu_flags_full()
{
local cpu_flags_full="$1" cpu_flags_1='' cpu_flags_2='' cpu_flags_3='' flag_data=''
local i=0 flag=''
-
+
for flag in $cpu_flags_full
do
if [[ $i -ge 36 ]];then
@@ -1562,10 +1566,10 @@ print_cpu_flags_full()
print_gfx_data()
{
- local gfx_data='' i='' card_one='Card '
+ local gfx_data='' i='' card_one='Card '
local screen_resolution="$( get_graphics_res_data )"
local b_is_mesa='false'
-
+
# set A_GFX_CARD_DATA
get_graphics_card_data
# set A_X_DATA
@@ -1577,7 +1581,7 @@ print_gfx_data()
local glx_renderer="${A_GLX_DATA[0]}"
local glx_version="${A_GLX_DATA[1]}"
local glx_direct_render="${A_GLX_DATA[2]}"
-
+
if [[ ${#A_GFX_CARD_DATA[@]} -gt 1 ]];then
i=1
while [[ -n ${A_GFX_CARD_DATA[i]} && $i -le 3 ]]
@@ -1595,11 +1599,11 @@ print_gfx_data()
gfx_data="${gfx_data} ${C1} tty resolution ${CN}(${C2} ${screen_resolution} ${CN})"
fi
print_screen_output "$gfx_data"
-
+
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' && $b_is_mesa != 'true' ]];then
gfx_data=$( create_print_line " " "${C1}GLX Renderer${C2} ${glx_renderer} ${CN}| ${C1}GLX Version${C2} ${glx_version}${CN}" )
@@ -1620,16 +1624,16 @@ print_hard_disk_data()
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
# set A_PARTITION_DATA
get_partition_data
-
+
for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ ))
do
IFS=","
a_partition_working=(${A_PARTITION_DATA[i]})
- IFS="$ORIGINAL_IFS"
+ IFS="$ORIGINAL_IFS"
partition_data="$partition_data ${C1}ID:${C2} ${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]} ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})"
done
# hdd_data=$( create_print_line " " "${C1}Partition:${C2} ${root_home_data}" )
@@ -1641,9 +1645,9 @@ print_hard_disk_data()
print_intro_data()
{
local intro_data='' host_name=$( hostname )
-
+
local distro="$( get_distro_data )"
-
+
if [[ $B_SHOW_HOST == 'true' ]];then
intro_data=$( create_print_line "System:" "${C1}Host${C2} $host_name ${C1}running${C2} ${CN}" )
else
@@ -1661,13 +1665,13 @@ print_networking_data()
IFS=","
a_network_working=(${A_NETWORK_DATA[0]})
- IFS="$ORIGINAL_IFS"
-
+ IFS="$ORIGINAL_IFS"
+
if [[ -n ${A_NETWORK_DATA[@]} ]];then
if [[ ${#A_NETWORK_DATA[@]} -le 1 ]];then
card_one='Card '
fi
-
+
if [[ -n ${a_network_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_network_working[1]}"
fi
@@ -1679,7 +1683,7 @@ print_networking_data()
do
IFS=","
a_network_working=( ${A_NETWORK_DATA[i]} )
- IFS="$ORIGINAL_IFS"
+ IFS="$ORIGINAL_IFS"
port_data=''
if [[ -n ${a_network_working[1]} ]];then
port_data=" ${C1}at port${C2} ${a_network_working[1]}"
@@ -1699,13 +1703,13 @@ print_short_data()
# this gets that weird min/max final array item
local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]}
-
+
#set_color_scheme 12
if [[ $B_RUNNING_IN_SHELL == 'false' ]];then
for i in $C1 $C2 $CN
do
- case "$i" in
- "$GREEN"|"$WHITE"|"$YELLOW"|"$CYAN")
+ case "$i" in
+ "$GREEN"|"$WHITE"|"$YELLOW"|"$CYAN")
b_background_black='true'
;;
esac
@@ -1740,21 +1744,21 @@ print_system_data()
local system_data=''
local runlvl="$( runlevel | gawk '{ print $2 }' )"
local memory="$( get_memory_data )"
-
+
# Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch!
# long_last=$( echo -ne "${C1}Processes${C2} ${processes}${CN} | ${C1}Uptime${C2} ${up_time}${CN} | ${C1}Memory${C2} ${MEM}${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
if [[ $B_X_RUNNING != 'true' ]];then
system_data="${system_data} ${CN}| ${C1}Runlevel${C2} ${runlvl}${CN}"
fi
-
+
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
system_data="${system_data} ${NORMAL}"
fi
@@ -1778,14 +1782,14 @@ print_it_out()
## assemble data for output
# load A_HDD_DATA
get_hard_drive_data
- ## note: if hdd_model is declared prior to use, whatever string you want inserted will
+ ## note: if hdd_model is declared prior to use, whatever string you want inserted will
## be inserted first. In this case, it's desirable to print out (x) before each disk found.
local hdd_model=${A_HDD_DATA[0]}
local hdd_capacity=${A_HDD_DATA[1]}
local hdd_used=${A_HDD_DATA[2]}
# load A_CPU_DATA
get_cpu_data
-
+
IFS=","
local a_cpu_working=(${A_CPU_DATA[0]})
IFS="$ORIGINAL_IFS"
@@ -1804,7 +1808,7 @@ print_it_out()
if [[ $VERBOSITY_LEVEL -ge 2 ]];then
print_networking_data
fi
-
+
print_hard_disk_data
print_system_data
;;
@@ -1865,4 +1869,4 @@ fi
# weechat's executor plugin forced me to do this, and rightfully so, because else the exit code
# from the last command is taken..
-exit 0
+exit 0