more refactoring and code cleanup, it's starting to get readable now

This commit is contained in:
inxi-svn 2008-10-28 03:01:58 +00:00
parent a5dd519b0f
commit 46f05dc2fc

26
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 0.1.6
#### version: 0.1.7
#### Date: October 27 2008
########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif
@ -38,7 +38,11 @@ ALLUP=0 # inxi hasn't been 'booted' yet.
DEBUG=0 # Set levels from 1-10
DEBUG_FLOOD=0 # Debug flood override: toggle on to allow long debug output
DBI=0 # Debug Buffer Index, index into a debug buffer storing debug messages until infobash is 'all up'
((DEBUG)) || exec 2>/dev/null # Reroute all error messages to the bitbucket (if not debugging)
if ! ((DEBUG))
then
# Reroute all error messages to the bitbucket (if not debugging)
exec 2>/dev/null
fi
#((DEBUG)) && exec 2>&1 # This is for debugging konversation
# Clear nullglob, because it creates unpredictable situations with IFS=$'\n' ARR=($VAR) IFS="$OIFS"
@ -79,10 +83,10 @@ 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
# version file should go first. (Such as with Sabayon / Gentoo)
DIST_DERIV="antiX kanotix-version knoppix-version redhat-release sabayon-release sidux-version turbolinux-release zenwalk-version"
DIST_MAIN="gentoo-release mandrake-release redhat-release slackware-version SuSE-release"
# debian_version excluded from DIST_MAIN so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
DIST_BLIST="debian_version ubuntu_version"
DISTROS_SECONDARY="antiX kanotix-version knoppix-version redhat-release sabayon-release sidux-version turbolinux-release zenwalk-version"
DISTROS_PRIMARY="gentoo-release mandrake-release redhat-release slackware-version SuSE-release"
# 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"
FL1='-' # These two determine seperators in single line output, to force irc clients not to break off sections
FL2=''
# Precede a banword with $'\2' to prevent it from being subject to automated escaping by the make_bans routine
@ -329,7 +333,10 @@ get_start_app()
# Since Konversation 1.0, the DCOP interface has changed a bit: dcop "$DCPORT" Konversation ..etc
# becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller
# than 1 and change the DCOP parameter/object accordingly.
[[ ${T2} < 1 ]] && DCOPOBJ="Konversation"
if [[ ${T2} < 1 ]]
then
DCOPOBJ="Konversation"
fi
IRC="Konversation"
;;
*xchat*)
@ -580,7 +587,7 @@ then
DISTFILE="${DISTGLOB}"
elif (( ${#DISTGLOB[@]} > 1 ))
then
for I in $DIST_DERIV $DIST_MAIN
for I in $DISTROS_SECONDARY $DISTROS_PRIMARY
do
# Only echo works with ${var[@]}, not print_screen_output() or script_debugger()
# This is a known bug, search for the word "strange" inside comments
@ -592,7 +599,7 @@ then
fi
done
fi
if [ -n "$DISTFILE" -a -s /etc/$DISTFILE -a " $DIST_BLIST " != *" $DISTFILE "* ]
if [ -n "$DISTFILE" -a -s /etc/$DISTFILE -a " $DISTROS_BLIST " != *" $DISTFILE "* ]
then
DISTRO=$( eat "/etc/$DISTFILE" )
else
@ -858,6 +865,7 @@ then
print(line)
}
' )
if [[ -z $RES ]]
then
RES=$( xdpyinfo | gawk '/dimensions/ { print $2 }' )