mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 08:57:57 +00:00
Cleaned up comments, made more consistent and easy to read, added some comments
This commit is contained in:
parent
1511341393
commit
f245bbc521
84
inxi
84
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.2.5
|
#### version: 0.2.6
|
||||||
#### Date: October 30 2008
|
#### Date: October 30 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
#### VARIABLES
|
#### VARIABLES
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
## Variable initializations: null values
|
### Variable initializations: null values
|
||||||
COLOR_SCHEME_SET=''
|
COLOR_SCHEME_SET=''
|
||||||
COLOR_SCHEME=''
|
COLOR_SCHEME=''
|
||||||
CPU_MODEL=''
|
CPU_MODEL=''
|
||||||
|
@ -48,39 +48,53 @@ CPU_FLAGS=''
|
||||||
IRC_CLIENT=''
|
IRC_CLIENT=''
|
||||||
IRC_CLIENT_VERSION=''
|
IRC_CLIENT_VERSION=''
|
||||||
|
|
||||||
## primary data array holders
|
### primary data array holders
|
||||||
A_CPU_DATA=''
|
A_CPU_DATA=''
|
||||||
A_GFX_CARD_DATA=''
|
A_GFX_CARD_DATA=''
|
||||||
A_GLX_DATA=''
|
A_GLX_DATA=''
|
||||||
A_NETWORK_DATA=''
|
A_NETWORK_DATA=''
|
||||||
A_X_DATA=''
|
A_X_DATA=''
|
||||||
|
|
||||||
## Boolean true/false globals
|
### Boolean true/false globals
|
||||||
B_RUNNING_IN_SHELL='false' # Running in a shell? Defaults to false, and is determined later.
|
# Running in a shell? Defaults to false, and is determined later.
|
||||||
B_SHOW_HOST='true' # Set this to 'false' to avoid printing the hostname
|
B_RUNNING_IN_SHELL='false'
|
||||||
|
# Set this to 'false' to avoid printing the hostname
|
||||||
|
B_SHOW_HOST='true'
|
||||||
B_X_RUNNING='false'
|
B_X_RUNNING='false'
|
||||||
|
|
||||||
# Variable initializations: constants
|
### Variable initializations: constants
|
||||||
ALLUP=0 # inxi hasn't been 'booted' yet.
|
# inxi hasn't been 'booted' yet.
|
||||||
CRAP=0 # New parameter
|
ALLUP=0
|
||||||
DBI=0 # Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up'
|
# New parameter
|
||||||
|
CRAP=0
|
||||||
|
# Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up'
|
||||||
|
DBI=0
|
||||||
DCOPOBJ="default"
|
DCOPOBJ="default"
|
||||||
DEBUG=0 # Set levels from 1-10
|
DEBUG=0 # Set debug levels from 1-10
|
||||||
DEBUG_FLOOD=0 # Debug flood override: toggle on to allow long debug output
|
# Debug flood override: toggle on to allow long debug output
|
||||||
DEFAULT_SCHEME=2 # 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.
|
DEBUG_FLOOD=0
|
||||||
FLAG=0 # A throw-away 'flag' variable intended to be used throughout inxi
|
# 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.
|
||||||
INDENT=10 # Default indentation level
|
DEFAULT_SCHEME=2
|
||||||
KONVI=0 # default to false, no konversation found, 1 is /cmd inxi start, 2 is native konvi script mode
|
# A throw-away 'flag' variable intended to be used throughout inxi
|
||||||
|
FLAG=0
|
||||||
|
# Default indentation level
|
||||||
|
INDENT=10
|
||||||
|
# default to false, no konversation found, 1 is /cmd inxi start, 2 is native konvi script mode
|
||||||
|
KONVI=0
|
||||||
LSPCI=$( lspci -v | awk '{ gsub(/\(prog-if[^)]*\)/,""); print }' )
|
LSPCI=$( lspci -v | awk '{ gsub(/\(prog-if[^)]*\)/,""); print }' )
|
||||||
# NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
|
# NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
|
||||||
PARAMETER_LIMIT=30 # This is a variable that controls how many parameters inxi will parse in a /proc/<pid>/cmdline file before stopping.
|
# This is a variable that controls how many parameters inxi will parse in a /proc/<pid>/cmdline file before stopping.
|
||||||
|
PARAMETER_LIMIT=30
|
||||||
SCHEME=0 # set default scheme
|
SCHEME=0 # set default scheme
|
||||||
SHOW_IRC=2 # SHOW_IRC=1 to avoid showing the irc client version number, or SHOW_IRC=0 to disable client information completely.
|
# SHOW_IRC=1 to avoid showing the irc client version number, or SHOW_IRC=0 to disable client information completely.
|
||||||
VERBOSITY_LEVEL=0 # Verbosity level defaults to 0, this can also be set with -v, -v2, -v3, etc as a parameter.
|
SHOW_IRC=2
|
||||||
VERBOSITY_LEVELS=4 # Supported number of verbosity levels
|
# Verbosity level defaults to 0, this can also be set with -v, -v2, -v3, etc as a parameter.
|
||||||
|
VERBOSITY_LEVEL=0
|
||||||
|
# Supported number of verbosity levels
|
||||||
|
VERBOSITY_LEVELS=4
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -91,23 +105,27 @@ fi
|
||||||
# type constructs. Stuff like [rev a1] is now seen as a glob expansion pattern, and fails, and
|
# type constructs. Stuff like [rev a1] is now seen as a glob expansion pattern, and fails, and
|
||||||
# therefore results in nothing. Tricky as fuck.
|
# therefore results in nothing. Tricky as fuck.
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
OIFS="$IFS" # Backup the current Internal Field Seperator
|
# Backup the current Internal Field Seperator
|
||||||
FL1='-' # These two determine separators in single line output, to force irc clients not to break off sections
|
OIFS="$IFS"
|
||||||
|
# These two determine separators in single line output, to force irc clients not to break off sections
|
||||||
|
FL1='-'
|
||||||
FL2=''
|
FL2=''
|
||||||
|
|
||||||
## Script names/paths
|
### Script names/paths
|
||||||
SCRIPT_NAME="inxi"
|
SCRIPT_NAME="inxi"
|
||||||
SCRIPT_PATH=$( dirname $0 )
|
SCRIPT_PATH=$( dirname $0 )
|
||||||
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}' )
|
||||||
SCRIPT_DATE=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3 " " $4 ", " $5}' )
|
SCRIPT_DATE=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3 " " $4 ", " $5}' )
|
||||||
KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data)
|
KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data)
|
||||||
|
|
||||||
## Script Localization
|
### Script Localization
|
||||||
LC_ALL="C" # Make sure every program speaks English.
|
# Make sure every program speaks English.
|
||||||
|
LC_ALL="C"
|
||||||
export LC_ALL
|
export LC_ALL
|
||||||
|
|
||||||
## Output Colors
|
### Output Colors
|
||||||
unset EMPTY # A more elegant way to have a scheme that doesn't print color codes (neither ANSI nor mIRC) at all. See below.
|
# A more elegant way to have a scheme that doesn't print color codes (neither ANSI nor mIRC) at all. See below.
|
||||||
|
unset EMPTY
|
||||||
# DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW
|
# 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"
|
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"
|
IRC_COLORS=" \x0314 \x0301 \x0304 \x0305 \x0309 \x0303 \x0308 \x0307"
|
||||||
|
@ -119,7 +137,7 @@ A_COLORS_AVAILABLE=( DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW BLUE DBLUE
|
||||||
# See above for notes on EMPTY
|
# See above for notes on EMPTY
|
||||||
A_COLOR_SCHEMES=( EMPTY,EMPTY,EMPTY NORMAL,NORMAL,NORMAL BLUE,NORMAL,NORMAL GREEN,YELLOW,NORMAL DYELLOW,NORMAL,NORMAL CYAN,BLUE,NORMAL RED,NORMAL,NORMAL GREEN,NORMAL,NORMAL YELLOW,NORMAL,NORMAL GREEN,DGREEN,NORMAL BLUE,RED,NORMAL BLUE,NORMAL,RED YELLOW,WHITE,GREEN BLUE,NORMAL,GREEN DCYAN,NORMAL,DMAGENTA )
|
A_COLOR_SCHEMES=( EMPTY,EMPTY,EMPTY NORMAL,NORMAL,NORMAL BLUE,NORMAL,NORMAL GREEN,YELLOW,NORMAL DYELLOW,NORMAL,NORMAL CYAN,BLUE,NORMAL RED,NORMAL,NORMAL GREEN,NORMAL,NORMAL YELLOW,NORMAL,NORMAL GREEN,DGREEN,NORMAL BLUE,RED,NORMAL BLUE,NORMAL,RED YELLOW,WHITE,GREEN BLUE,NORMAL,GREEN DCYAN,NORMAL,DMAGENTA )
|
||||||
|
|
||||||
## Distro Data
|
### 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)
|
# the derived distro's version file should go first. (Such as with Sabayon / Gentoo)
|
||||||
DISTROS_DERIVED="antiX kanotix-version knoppix-version redhat-release sabayon-release sidux-version turbolinux-release zenwalk-version"
|
DISTROS_DERIVED="antiX kanotix-version knoppix-version redhat-release sabayon-release sidux-version turbolinux-release zenwalk-version"
|
||||||
|
@ -127,7 +145,7 @@ DISTROS_PRIMARY="gentoo-release mandrake-release redhat-release slackware-versio
|
||||||
# debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
|
# debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
|
||||||
DISTROS_BLIST="debian_version ubuntu_version"
|
DISTROS_BLIST="debian_version ubuntu_version"
|
||||||
|
|
||||||
## Bans Data
|
### Bans Data
|
||||||
# Precede a banword with $'\2' to prevent it from being subject to automated escaping by the make_bans routine
|
# Precede a banword with $'\2' to prevent it from being subject to automated escaping by the make_bans routine
|
||||||
# $'\1' gets weird results :
|
# $'\1' gets weird results :
|
||||||
# user@host $ ARR=($'\x01'"one two" three four); echo ${ARR[0]} | hd -v
|
# user@host $ ARR=($'\x01'"one two" three four); echo ${ARR[0]} | hd -v
|
||||||
|
@ -135,7 +153,7 @@ DISTROS_BLIST="debian_version ubuntu_version"
|
||||||
A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'\2'"\<ltd\>" ltd. $'\2'"\<inc\>" inc. $'\2'\<co\> co. "(tm)" "(r)" $'\2'"\(rev ..\)" )
|
A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'\2'"\<ltd\>" ltd. $'\2'"\<inc\>" inc. $'\2'\<co\> co. "(tm)" "(r)" $'\2'"\(rev ..\)" )
|
||||||
A_CPU_BANS=( core cpu deca dual ennea genuine hepta hexa multi octa penta processor quad single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
|
A_CPU_BANS=( core cpu deca dual ennea genuine hepta hexa multi octa penta processor quad 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
|
||||||
|
@ -162,6 +180,7 @@ error_handler()
|
||||||
{
|
{
|
||||||
local error_message=''
|
local error_message=''
|
||||||
|
|
||||||
|
# assemble the error message
|
||||||
case $1 in
|
case $1 in
|
||||||
2)
|
2)
|
||||||
error_message="$SCRIPT_NAME: large flood danger, debug buffer full!"
|
error_message="$SCRIPT_NAME: large flood danger, debug buffer full!"
|
||||||
|
@ -189,6 +208,7 @@ error_handler()
|
||||||
set -- 99
|
set -- 99
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
# then print it and exit
|
||||||
print_screen_output "$error_message"
|
print_screen_output "$error_message"
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue