mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
more refactoring
This commit is contained in:
parent
05ad16866c
commit
6d63e5686b
50
inxi
50
inxi
|
@ -10,7 +10,8 @@
|
||||||
#### inxi, the universal, portable, system info script for irc.
|
#### inxi, the universal, portable, system info script for irc.
|
||||||
#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
|
#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
|
||||||
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
|
#### Gaim/Pidgin, Weechat, KVIrc and Kopete.
|
||||||
#### Copyright (C) 2005-2007 locsmif <infobash@rebelhomicide.demon.nl>
|
#### Original infobash author and copyright holder:
|
||||||
|
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif <infobash@rebelhomicide.demon.nl>
|
||||||
####
|
####
|
||||||
#### This program is free software; you can redistribute it and/or modify
|
#### 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
|
#### it under the terms of the GNU General Public License as published by
|
||||||
|
@ -74,10 +75,6 @@ OIFS="$IFS" # Backup the current Internal Field Seperator
|
||||||
FL1='-' # These two determine separators in single line output, to force irc clients not to break off sections
|
FL1='-' # These two determine separators in single line output, to force irc clients not to break off sections
|
||||||
FL2=''
|
FL2=''
|
||||||
|
|
||||||
## Variable initializations: script parameter/option globals
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Script names/paths
|
## Script names/paths
|
||||||
SCRIPT_NAME="inxi"
|
SCRIPT_NAME="inxi"
|
||||||
SCRIPT_PATH=$( dirname $0 )
|
SCRIPT_PATH=$( dirname $0 )
|
||||||
|
@ -120,7 +117,7 @@ NORMAL_BANS=( corporation communications technologies technology group $'\2'"\<l
|
||||||
CPU_BANS=( cpu processor $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
|
CPU_BANS=( cpu processor $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" )
|
||||||
|
|
||||||
|
|
||||||
EXTRA_PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" # Extra path variable to make execute failures less likely, merged below
|
|
||||||
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)
|
||||||
|
|
||||||
# Source global config overrides
|
# Source global config overrides
|
||||||
|
@ -179,9 +176,9 @@ error_handler()
|
||||||
|
|
||||||
script_debugger()
|
script_debugger()
|
||||||
{
|
{
|
||||||
if (( ALLUP ))
|
if [ "$ALLUP" -gt 0 ]
|
||||||
then
|
then
|
||||||
if ! (( DEBUG ))
|
if [ "$DEBUG" -eq 0 ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -195,7 +192,7 @@ script_debugger()
|
||||||
fi
|
fi
|
||||||
print_screen_output "$@"
|
print_screen_output "$@"
|
||||||
else
|
else
|
||||||
if ((!DEBUG_FLOOD && DBI>10))
|
if ((!DEBUG_FLOOD && DBI > 10))
|
||||||
then
|
then
|
||||||
error_handler 2
|
error_handler 2
|
||||||
fi
|
fi
|
||||||
|
@ -316,7 +313,7 @@ make_bans()
|
||||||
# $1 = <scheme number>|<"none">
|
# $1 = <scheme number>|<"none">
|
||||||
set_color_scheme()
|
set_color_scheme()
|
||||||
{
|
{
|
||||||
local i='' scriptColors='' colorCodes=''
|
local i='' script_colors='' color_codes=''
|
||||||
|
|
||||||
if [[ $1 -ge ${#COLOR_SCHEMES[@]} ]]
|
if [[ $1 -ge ${#COLOR_SCHEMES[@]} ]]
|
||||||
then
|
then
|
||||||
|
@ -325,20 +322,20 @@ set_color_scheme()
|
||||||
SCHEME="$1" # Set a global variable to allow checking for chosen scheme later
|
SCHEME="$1" # Set a global variable to allow checking for chosen scheme later
|
||||||
if ((IBSHELL))
|
if ((IBSHELL))
|
||||||
then
|
then
|
||||||
colorCodes=($ANSI_COLORS)
|
color_codes=($ANSI_COLORS)
|
||||||
else
|
else
|
||||||
colorCodes=($IRC_COLORS)
|
color_codes=($IRC_COLORS)
|
||||||
fi
|
fi
|
||||||
for (( i=0; i < ${#COLORS_AVAILABLE[@]}; i++ ))
|
for (( i=0; i < ${#COLORS_AVAILABLE[@]}; i++ ))
|
||||||
do
|
do
|
||||||
eval "${COLORS_AVAILABLE[i]}=\"${colorCodes[i]}\""
|
eval "${COLORS_AVAILABLE[i]}=\"${color_codes[i]}\""
|
||||||
done
|
done
|
||||||
IFS=","
|
IFS=","
|
||||||
scriptColors=(${COLOR_SCHEMES[$1]})
|
script_colors=(${COLOR_SCHEMES[$1]})
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
C1="${!scriptColors[0]}"
|
C1="${!script_colors[0]}"
|
||||||
C2="${!scriptColors[1]}"
|
C2="${!script_colors[1]}"
|
||||||
CN="${!scriptColors[2]}"
|
CN="${!script_colors[2]}"
|
||||||
((CSCHEME++))
|
((CSCHEME++))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,34 +581,35 @@ get_start_source()
|
||||||
|
|
||||||
set_calculated_variables()
|
set_calculated_variables()
|
||||||
{
|
{
|
||||||
local i='' j=''
|
local path='' sys_path='' added_path=''
|
||||||
|
# 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 "X" accordingly
|
# Detect X and set variable "X" accordingly
|
||||||
if [[ $DISPLAY ]]
|
if [ -n "$DISPLAY" ]
|
||||||
then
|
then
|
||||||
X=1
|
X=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fallback paths put into $EXTRA_PATH; This might, among others, help on gentoo.
|
# Fallback paths put into $EXTRA_PATH; This might, among others, help on gentoo.
|
||||||
# Now, create a difference of $PATH and $EXTRA_PATH and add that to $PATH:
|
# Now, create a difference of $PATH and $EXTRA_PATH and add that to $PATH:
|
||||||
unset TPATH
|
|
||||||
IFS=":"
|
IFS=":"
|
||||||
for i in $EXTRA_PATH
|
for path in $extra_paths
|
||||||
do
|
do
|
||||||
FLAG=0
|
FLAG=0
|
||||||
for j in $PATH
|
for sys_path in $PATH
|
||||||
do
|
do
|
||||||
if [[ $i = $j ]]
|
if [ "$path" == "$sys_path" ]
|
||||||
then
|
then
|
||||||
FLAG=1
|
FLAG=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if ! ((FLAG))
|
if [ "$FLAG" -eq 0 ]
|
||||||
then
|
then
|
||||||
TPATH="$TPATH:$i"
|
added_path="$added_path:$path"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
PATH="${PATH}${TPATH}"
|
PATH="${PATH}${added_path}"
|
||||||
##echo "PATH='$PATH'"
|
##echo "PATH='$PATH'"
|
||||||
##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
|
##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue