(Change Version)

This is another milestone, hit much sooner than we thought. We have now restored the broken konversation native script 
support.

This will be of special interest to distros who want to include inxi as native, or to packagers.

Basically, all that is needed is to set this symbolic link:

ln -s <inxi location, ie: /usr/bin/inxi, or /usr/local/bin/inxi> /var/share/apps/konversation/scripts/inxi

in the package post install script.

This will automatically enable native, ie: /inxi support in konversation.

Fixed a few other small bugs, and cleaned up code and comments as well.

We were almost going to call this release 1.0.0, but we'll leave that until it's absolutely certain that everything is 
debugged and working.
This commit is contained in:
inxi-svn 2008-11-24 01:46:31 +00:00
parent 752420c0a4
commit 5e8f77fd64

58
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 0.6.2 #### version: 0.7.0
#### Date: November 22 2008 #### Date: November 23 2008
######################################################################## ########################################################################
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif #### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
#### As time permits functionality improvements and recoding will occur. #### As time permits functionality improvements and recoding will occur.
@ -30,6 +30,9 @@
#### ####
#### You should have received a copy of the GNU General Public License #### You should have received a copy of the GNU General Public License
#### along with this program. If not, see <http://www.gnu.org/licenses/>. #### along with this program. If not, see <http://www.gnu.org/licenses/>.
####
#### If you don't understand what Free Software is, please read (or reread)
#### this page: http://www.gnu.org/philosophy/free-sw.html
######################################################################## ########################################################################
#### DEPENDENCIES #### DEPENDENCIES
#### bash >=2.05b(bash), df;readlink;stty;tr;uname;wc(coreutils), #### bash >=2.05b(bash), df;readlink;stty;tr;uname;wc(coreutils),
@ -65,6 +68,10 @@
#### The color variable ${C2} must always be followed by a space unless you know what #### The color variable ${C2} must always be followed by a space unless you know what
#### character is going to be next for certain. Otherwise irc color codes can be accidentally #### character is going to be next for certain. Otherwise irc color codes can be accidentally
#### activated or altered. #### activated or altered.
####
#### For native script konversation support (check distro for correct konvi scripts path):
#### ln -s <path to inxi> /usr/share/apps/konversation/scripts/inxi
#### DCOP doesn't like \n, so avoid using it for most output unless required, as in error messages.
######################################################################## ########################################################################
#### TESTING FLAGS #### TESTING FLAGS
#### inxi supports advanced testing triggers to do various things, using -! <arg> #### inxi supports advanced testing triggers to do various things, using -! <arg>
@ -326,30 +333,32 @@ script_debugger()
#### print / output cleaners #### print / output cleaners
#### ------------------------------------------------------------------- #### -------------------------------------------------------------------
# inxi speaks through here. When run by Konversation, uses DCOP # inxi speaks through here. When run by Konversation script alias mode, uses DCOP
# note, this is a huge bug trap, for now we're not using this at all except to # for dcop to work, must use 'say' operator, AND colors must be evaluated by echo -e
# output basic stuff. At some point in the future we'll debug the dcop stuff, # note: dcop does not seem able to handle \n so that's being stripped out and replaced with space.
# but that only works if inxi is being run as a konversation script to begin with
print_screen_output() print_screen_output()
{ {
# the double quotes are needed to avoid losing whitespace in data when certain output types are used
local print_data="$( echo -e "$1" )"
if [[ $DEBUG -gt 5 ]];then if [[ $DEBUG -gt 5 ]];then
if [[ $KONVI -eq 1 ]];then if [[ $KONVI -eq 1 ]];then
dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$@'" # konvi doesn't seem to like \n characters, it just prints them literally
print_data="$( tr '\n' ' ' <<< "$print_data" )"
dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$print_data'"
elif [[ $KONVI -eq 2 ]];then
echo "konvi='$KONVI' saying : '$print_data'"
else else
echo "konvi='$KONVI' saying : '$@'" echo "printing out: '$print_data'"
fi fi
#echo "konvi='$KONVI' saying : '$@'"
#((KONVI)) && dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$@'" || echo "konvi='$KONVI' saying : '$@'"
fi fi
#((KONVI)) && dcop $DCPORT Konversation print_screen_output $DCSERVER "$DCTARGET" "$1" || echo -ne "$1\n"
if [[ $KONVI -eq 1 ]];then if [[ $KONVI -eq 1 ]];then
dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "$1" print_data="$( tr '\n' ' ' <<< "$print_data" )"
dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "$print_data"
else else
echo -ne "$1\n" echo -e "$print_data\n"
fi fi
#((KONVI)) && dcop "$DCPORT" "$DCOPOBJ" print_screen_output "$DCSERVER" "$DCTARGET" "$1" || echo -ne "$1\n"
# echo -ne "$1\n"
} }
## this handles all verbose line construction with indentation/line starter ## this handles all verbose line construction with indentation/line starter
@ -404,6 +413,8 @@ sanitize_characters()
check_script_depends() check_script_depends()
{ {
local app_name='' app_data='' local app_name='' app_data=''
# bc removed from deps for now
local depends="df free gawk grep hostname lspci ps readlink runlevel tr uname uptime wc"
if [[ ! -d /proc/ ]];then if [[ ! -d /proc/ ]];then
error_handler 6 error_handler 6
@ -414,7 +425,7 @@ check_script_depends()
do do
app_data=$( type -p $app_name ) app_data=$( type -p $app_name )
if [[ -z $app_data ]];then if [[ -z $app_data ]];then
script_debugger "inxi: Resuming in non X mode: $app_name not found in path" script_debugger "Resuming in non X mode: $app_name not found in path"
B_X_RUNNING='false' B_X_RUNNING='false'
break break
fi fi
@ -422,8 +433,8 @@ check_script_depends()
fi fi
app_name='' 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 for app_name in $depends
do do
app_data=$( type -p $app_name ) app_data=$( type -p $app_name )
if [[ -z $app_data ]];then if [[ -z $app_data ]];then
@ -467,7 +478,8 @@ set_color_scheme()
if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]];then if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]];then
set -- 1 set -- 1
fi fi
SCHEME="$1" # Set a global variable to allow checking for chosen scheme later # Set a global variable to allow checking for chosen scheme later
SCHEME="$1"
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
color_codes=( $ANSI_COLORS ) color_codes=( $ANSI_COLORS )
else else
@ -480,6 +492,7 @@ set_color_scheme()
IFS="," IFS=","
script_colors=( ${A_COLOR_SCHEMES[$1]} ) script_colors=( ${A_COLOR_SCHEMES[$1]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
# then assign the colors globally
C1="${!script_colors[0]}" C1="${!script_colors[0]}"
C2="${!script_colors[1]}" C2="${!script_colors[1]}"
CN="${!script_colors[2]}" CN="${!script_colors[2]}"
@ -760,7 +773,8 @@ script_self_updater()
wget -q -O $SCRIPT_PATH/$SCRIPT_NAME $1$SCRIPT_NAME || wget_error=$? wget -q -O $SCRIPT_PATH/$SCRIPT_NAME $1$SCRIPT_NAME || wget_error=$?
if [[ $wget_error -eq 0 ]];then if [[ $wget_error -eq 0 ]];then
SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' ) SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' )
print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER\nTo run the new version, just start $SCRIPT_NAME again." print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER"
print_screen_output "To run the new version, just start $SCRIPT_NAME again."
exit 0 exit 0
fi fi
fi fi
@ -1841,8 +1855,8 @@ get_networking_wan_ip_data()
{ {
local ip='' local ip=''
# get ip using wget redirect to stdout # get ip using wget redirect to stdout. This is a clean, text only IP output url.
ip=$( wget -q -O - http://techpatterns.com/resources/ip.php | awk -F 'is: ' '{ ip=$( wget -q -O - http://smxi.org/opt/ip.php | awk -F 'is: ' '{
#gsub("\n","",$2") #gsub("\n","",$2")
print $2 print $2
}' ) }' )