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.
|
# therefore results in nothing. Tricky as fuck.
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
|
|
||||||
########################################################################
|
|
||||||
#### UNCALCULATED VARIABLES
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
SCRIPT_NAME="inxi"
|
SCRIPT_NAME="inxi"
|
||||||
SCRIPT_LOWER_CASE=$( tr '[A-Z]' '[a-z]' <<< $SCRIPT_NAME )
|
SCRIPT_LOWER_CASE=$( tr '[A-Z]' '[a-z]' <<< $SCRIPT_NAME )
|
||||||
SCRIPT_PATH=$( dirname $0 )
|
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_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.
|
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
|
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.
|
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.
|
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
|
# 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)
|
-v|-v[1-9]|--verbose)
|
||||||
if [[ ${#1} -eq 3 ]]
|
if [[ ${#1} -eq 3 ]]
|
||||||
then
|
then
|
||||||
VBL="${1:2}"
|
VERBOSITY_LEVEL="${1:2}"
|
||||||
else
|
else
|
||||||
if [[ $2 = --* || $2 = -* || -z $2 ]]
|
if [[ $2 = --* || $2 = -* || -z $2 ]]
|
||||||
then
|
then
|
||||||
VBL=1
|
VERBOSITY_LEVEL=1
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
VBL="$1"
|
VERBOSITY_LEVEL="$1"
|
||||||
fi
|
fi
|
||||||
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)
|
-U)
|
||||||
print_screen_output "Updating $SCRIPT_NAME now..."
|
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 }' )
|
RES=$( stty -F $( readlink /proc/$PPID/fd/0 ) size | gawk '{ print $2"x"$1 }' )
|
||||||
RUNLVL=$( runlevel | gawk '{ print $2 }' )
|
RUNLVL=$( runlevel | gawk '{ print $2 }' )
|
||||||
fi
|
fi
|
||||||
# (IF VBL > 1)
|
# (IF VERBOSITY_LEVEL > 1)
|
||||||
if ((VBL))
|
if ((VERBOSITY_LEVEL))
|
||||||
then
|
then
|
||||||
if ((SHOW_HOST))
|
if ((SHOW_HOST))
|
||||||
then
|
then
|
||||||
|
@ -983,7 +979,7 @@ then
|
||||||
unset CPUNUM
|
unset CPUNUM
|
||||||
fi
|
fi
|
||||||
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" "CPU Info" "${CPUNUM}${CPUNUM+ }${CPUTMP[0]}" )
|
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" "CPU Info" "${CPUNUM}${CPUNUM+ }${CPUTMP[0]}" )
|
||||||
if [[ $VBL -ge 3 ]]
|
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
||||||
then
|
then
|
||||||
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||||
fi
|
fi
|
||||||
|
@ -996,7 +992,7 @@ then
|
||||||
CPUTMP=(${CPU[I]})
|
CPUTMP=(${CPU[I]})
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" " " "($((I+1))) ${CPUTMP[0]}" )
|
LNCPU=$( printf "${C1}%-${INDENT}s${C2} %s" " " "($((I+1))) ${CPUTMP[0]}" )
|
||||||
if [[ $VBL -ge 3 ]]
|
if [[ $VERBOSITY_LEVEL -ge 3 ]]
|
||||||
then
|
then
|
||||||
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
LNCPU=$( printf "%s${C2} %s %s ${C1}%s${CN}%s${C2} %s ${CN}%s" "$LNCPU" "${CPUTMP[2]}" "cache" "flags" "(" "$CPUFLAGS" ")" )
|
||||||
fi
|
fi
|
||||||
|
@ -1026,7 +1022,7 @@ then
|
||||||
(( I++ ))
|
(( I++ ))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $VBL -ge 2 ]]
|
if [[ $VERBOSITY_LEVEL -ge 2 ]]
|
||||||
then
|
then
|
||||||
IFS=$'\n' LNNET=($( echo "$LSPCI" | gawk '
|
IFS=$'\n' LNNET=($( echo "$LSPCI" | gawk '
|
||||||
BEGIN { IGNORECASE=1 }
|
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!
|
# 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}" )
|
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
|
then
|
||||||
LNLAST="${LNLAST}$( echo -ne " | ${C1}HDD${C2} ${HDDMOD} ${C1}Size${C2} ${HDD} (${HDDUSG})${CN}" )"
|
LNLAST="${LNLAST}$( echo -ne " | ${C1}HDD${C2} ${HDDMOD} ${C1}Size${C2} ${HDD} (${HDDUSG})${CN}" )"
|
||||||
else
|
else
|
||||||
|
@ -1109,7 +1105,7 @@ then
|
||||||
LNLAST="${LNLAST}$( echo -ne "${NORMAL}" )"
|
LNLAST="${LNLAST}$( echo -ne "${NORMAL}" )"
|
||||||
fi
|
fi
|
||||||
print_screen_output "$LNLAST"
|
print_screen_output "$LNLAST"
|
||||||
else # (IF VBL > 1 ... ELSE)
|
else # (IF VERBOSITY_LEVEL > 1 ... ELSE)
|
||||||
#set_color_scheme 12
|
#set_color_scheme 12
|
||||||
if ! ((IBSHELL))
|
if ! ((IBSHELL))
|
||||||
then
|
then
|
||||||
|
@ -1145,11 +1141,12 @@ else # (IF VBL > 1 ... ELSE)
|
||||||
LNSHORT="${LNSHORT}$( echo -ne "$NORMAL" )"
|
LNSHORT="${LNSHORT}$( echo -ne "$NORMAL" )"
|
||||||
fi
|
fi
|
||||||
print_screen_output "$LNSHORT"
|
print_screen_output "$LNSHORT"
|
||||||
fi # (IF VBL > 1)
|
fi # (IF VERBOSITY_LEVEL > 1)
|
||||||
|
|
||||||
## end main_temp_engine
|
## end main_temp_engine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#### SCRIPT EXECUTION
|
#### SCRIPT EXECUTION
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
Loading…
Reference in a new issue