mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
refactoring
This commit is contained in:
parent
f335326cd9
commit
862eb60967
31
inxi
31
inxi
|
@ -50,10 +50,6 @@ fi
|
|||
# therefore results in nothing. Tricky as fuck.
|
||||
shopt -u nullglob
|
||||
|
||||
########################################################################
|
||||
#### UNCALCULATED VARIABLES
|
||||
########################################################################
|
||||
|
||||
SCRIPT_NAME="inxi"
|
||||
SCRIPT_LOWER_CASE=$( tr '[A-Z]' '[a-z]' <<< $SCRIPT_NAME )
|
||||
SCRIPT_PATH=$( dirname $0 )
|
||||
|
@ -79,7 +75,7 @@ DEFAULT_SCHEME=2 # Defaults to 2, make this 1 for normal, 0 for no colorcodes at
|
|||
SHOW_HOST=1 # Set this to 0 to avoid printing the hostname
|
||||
SHOW_IRC=2 # SHOW_IRC=1 to avoid showing the irc client version number, or SHOW_IRC=0 to disable client information completely.
|
||||
INDENT=14 # Default indentation level
|
||||
VBL=0 # Verbosity level defaults to 0, this can also be set with -v, -v2, -v3, etc as a parameter.
|
||||
VERBOSITY_LEVEL=0 # Verbosity level defaults to 0, this can also be set with -v, -v2, -v3, etc as a parameter.
|
||||
IBSHELL=0 # Running in a shell? Defaults to false, and is determined later.
|
||||
NO_CPU_COUNT=0 # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
|
||||
# In cases of derived distros where the version file of the base distro can also be found under /etc, the derived distro's
|
||||
|
@ -445,17 +441,17 @@ get_parameters()
|
|||
-v|-v[1-9]|--verbose)
|
||||
if [[ ${#1} -eq 3 ]]
|
||||
then
|
||||
VBL="${1:2}"
|
||||
VERBOSITY_LEVEL="${1:2}"
|
||||
else
|
||||
if [[ $2 = --* || $2 = -* || -z $2 ]]
|
||||
then
|
||||
VBL=1
|
||||
VERBOSITY_LEVEL=1
|
||||
else
|
||||
shift
|
||||
VBL="$1"
|
||||
VERBOSITY_LEVEL="$1"
|
||||
fi
|
||||
fi
|
||||
echo "$VBL" | grep -q '^[1-3]$' || error_handler 4 "$VBL"
|
||||
echo "$VERBOSITY_LEVEL" | grep -q '^[1-3]$' || error_handler 4 "$VERBOSITY_LEVEL"
|
||||
;;
|
||||
-U)
|
||||
print_screen_output "Updating $SCRIPT_NAME now..."
|
||||
|
@ -947,8 +943,8 @@ else
|
|||
RES=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{ print $2"x"$1 }' )
|
||||
RUNLVL=$( runlevel | gawk '{ print $2 }' )
|
||||
fi
|
||||
# (IF VBL > 1)
|
||||
if ((VBL))
|
||||
# (IF VERBOSITY_LEVEL > 1)
|
||||
if ((VERBOSITY_LEVEL))
|
||||
then
|
||||
if ((SHOW_HOST))
|
||||
then
|
||||
|
@ -983,7 +979,7 @@ then
|
|||
unset CPUNUM
|
||||
fi
|
||||
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" "CPU Info" "${CPUNUM}${CPUNUM+ }${CPUTMP[0]}" )
|
||||
if [[ $VBL -ge 3 ]]
|
||||
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
||||
then
|
||||
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||
fi
|
||||
|
@ -996,7 +992,7 @@ then
|
|||
CPUTMP=(${CPU[I]})
|
||||
IFS="$OIFS"
|
||||
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" " " "($((I+1))) ${CPUTMP[0]}" )
|
||||
if [[ $VBL -ge 3 ]]
|
||||
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
||||
then
|
||||
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||
fi
|
||||
|
@ -1026,7 +1022,7 @@ then
|
|||
(( I++ ))
|
||||
done
|
||||
|
||||
if [[ $VBL -ge 2 ]]
|
||||
if [[ $VERBOSITY_LEVEL -ge 2 ]]
|
||||
then
|
||||
IFS=$'\n' LNNET=($( echo "$LSPCI" | gawk '
|
||||
BEGIN { IGNORECASE=1 }
|
||||
|
@ -1078,7 +1074,7 @@ then
|
|||
|
||||
# Some code could look superfluous but BitchX doesn't like lines not ending in a newline. F*&k that bitch!
|
||||
LNLAST=$( echo -ne "${C1}Processes${C2} ${PROC}${CN} | ${C1}Uptime${C2} ${UPT}${CN} | ${C1}Memory${C2} ${MEM}${CN}" )
|
||||
if [[ $VBL -ge 2 ]]
|
||||
if [[ $VERBOSITY_LEVEL -ge 2 ]]
|
||||
then
|
||||
LNLAST="${LNLAST}$( echo -ne " | ${C1}HDD${C2} ${HDDMOD} ${C1}Size${C2} ${HDD} (${HDDUSG})${CN}" )"
|
||||
else
|
||||
|
@ -1109,7 +1105,7 @@ then
|
|||
LNLAST="${LNLAST}$( echo -ne "${NORMAL}" )"
|
||||
fi
|
||||
print_screen_output "$LNLAST"
|
||||
else # (IF VBL > 1 ... ELSE)
|
||||
else # (IF VERBOSITY_LEVEL > 1 ... ELSE)
|
||||
#set_color_scheme 12
|
||||
if ! ((IBSHELL))
|
||||
then
|
||||
|
@ -1145,11 +1141,12 @@ else # (IF VBL > 1 ... ELSE)
|
|||
LNSHORT="${LNSHORT}$( echo -ne "$NORMAL" )"
|
||||
fi
|
||||
print_screen_output "$LNSHORT"
|
||||
fi # (IF VBL > 1)
|
||||
fi # (IF VERBOSITY_LEVEL > 1)
|
||||
|
||||
## end main_temp_engine
|
||||
}
|
||||
|
||||
|
||||
########################################################################
|
||||
#### SCRIPT EXECUTION
|
||||
########################################################################
|
||||
|
|
Loading…
Reference in a new issue