Update inxi to 3.0.18
authorMichael Marley <michael@michaelmarley.com>
Wed, 18 Jul 2018 00:09:15 +0000 (20:09 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 18 Jul 2018 20:14:34 +0000 (22:14 +0200)
data/scripts/inxi

index fc9550f..a444e66 100755 (executable)
-#!/usr/bin/env bash
-########################################################################
-####  Script Name: inxi
-####  Version: 2.3.0
-####  Date: 2016-04-18
-####  Patch Number: 00
-########################################################################
-####  SPECIAL THANKS
-########################################################################
-####  Special thanks to all those in #lsc and #smxi for their tireless 
-####  dedication helping test inxi modules.
-########################################################################
-####  ABOUT INXI
-########################################################################
-####  inxi is a fork of infobash 3.02, the original bash sys info tool by locsmif
-####  As time permits functionality improvements and recoding will occur.
-####
-####  inxi, the universal, portable, system information tool for irc.
-####  Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
-####  Gaim/Pidgin, Weechat, KVIrc and Kopete.
-####  Original infobash author and copyright holder:
-####  Copyright (C) 2005-2007  Michiel de Boer a.k.a. locsmif
-####  inxi version: Copyright (C) 2008-2016 Scott Rogers & Harald Hope
-####  Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
-####  Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
-####  Jarett.Stevens - dmidecde -M patch for older systems with the /sys 
-####
-####  Current script home page/wiki/git: https://github.com/smxi/inxi 
-####  Documentation/wiki pages will move to http://smxi.org soon.
-####  Script forums: http://techpatterns.com/forums/forum-33.html
-####  IRC support: irc.oftc.net channel #smxi
-####  Version control:
-####   * https://github.com/smxi/inxi
-####   * git: git pull https://github.com/smxi/inxi master
-####   * svn checkout url: https://github.com/smxi/inxi
-####
-####  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
-####  the Free Software Foundation; either version 3 of the License, or
-####  (at your option) any later version.
-####
-####  This program is distributed in the hope that it will be useful,
-####  but WITHOUT ANY WARRANTY; without even the implied warranty of
-####  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-####  GNU General Public License for more details.
-####
-####  You should have received a copy of the GNU General Public License
-####  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
-########################################################################
-
-####
-#### PACKAGE NAME NOTES
-####  * Package names in (...) are the Debian Squeeze package name. Check your 
-####    distro for proper package name by doing this: which <application> 
-####    then find what package owns that application file. Or run --recommends
-####    which shows package names for Debian/Ubuntu, Arch, and Fedora/Redhat/Suse
-####
-####  DEPENDENCIES
-####  * bash >=3.0 (bash); df, readlink, stty, tr, uname, wc (coreutils);
-####    gawk (gawk); grep (grep); lspci (pciutils);
-####    ps, find (findutils)
-####  * Also the proc filesystem should be present and mounted for Linux
-####  * Some features, like -M and -d will not work, or will work incompletely,
-####    if /sys is missing
-####
-####   Apparently unpatched bash 3.0 has arrays broken; bug reports:
-####   http://ftp.gnu.org/gnu/bash/bash-3.0-patches/bash30-008
-####   http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00144.html
-####  Bash 3.1 for proper array use
-####
-####   Arrays work in bash 2.05b, but "grep -Em" does not
-####
-####  RECOMMENDS (Needed to run certain features, listed by option)
-####  -A - for output of usb audio information: lsusb (usbutils)
-####  -Ax -Nx - for audio/network module version: modinfo (module-init-tools)
-####  -Dx - for hdd temp output (root only default): hddtemp (hddtemp)
-####       For user level hdd temp output: sudo (sudo)
-####       Note: requires user action for this feature to run as user (edit /etc/sudoers file)
-####  -G - full graphics output requires:  glxinfo (mesa-utils); xdpyinfo (X11-utils);
-####       xrandr (x11-xserver-utils)
-####  -i - IP information, local/wan - ip (iproute) legacy, not used if ip present: ifconfig (net-tools)
-####  -I - uptime (procps, check Debian if changed)
-####  -Ix - view current runlevel while not in X window system (or with -x): runlevel (sysvinit)
-####  -m - all systems, dmidecode, unless someone can find a better way.
-####  -M - for older systems whose kernel does not have /sys data for machine, dmidecode (dmidecode)
-####  -o - for unmounted file system information in unmounted drives (root only default): file (file)
-####       Note: requires user action for this feature to run as user (edit /etc/sudoers file)
-####       For user level unmounted file system type output: sudo (sudo)
-####  -s   For any sensors output, fan, temp, etc: sensors (lm-sensors)
-####       Note: requires setup of lm-sensors (sensors-detect and adding modules/modprobe/reboot,
-####       and ideally, pwmconfig) prior to full output being available. 
-####  -S   For desktop environment, user must be in X and have xprop installed (in X11-utils)
-########################################################################
-####  BSD Adjustments
-####  * sed -i '' form supported by using SED_I="-i ''".
-####  * Note: New BSD sed supports using -r instead of -E for compatibility with gnu sed
-####    However, older, like FreeBSD 7.x, does not have -r so using SED_RX='-E' for this.
-####  * Gnu grep options can be used if the function component is only run in linux
-####    These are the options that bsd grep does not support that inxi uses: -m <number> -o 
-####    so make sure if you use those to have them in gnu/linux only sections.
-####    It appears that freebsd uses gnu grep but openbsd uses bsd grep, however.
-####  * BSD ps does not support --without-headers option, and also does not support --sort <option>
-####    Tests show that -m fails to sort memory as expected, but -r does sort cpu percentage.
-####  * BSD_TYPE is set with values null, debian-bsd (debian gnu/kfreebsd), bsd (all other bsds)
-####  * Subshell and array closing ) must not be on their own line unless you use an explicit \ 
-####    to indicate that logic continues to next line where closing ) or )) are located.
-########################################################################
-####  CONVENTIONS:
-####  * Character Encoding: UTF-8 - this file contains special characters that must be opened and saved as UTF8
-####  * Indentation: TABS
-####  * Do not use `....` (back quotes), those are totally non-reabable, use $(....).
-####  * Do not use one liner flow controls. 
-####    The ONLY time you should use ';' (semi-colon) is in this single case: if [[ condition ]];then.
-####    Never use compound 'if': ie, if [[ condition ]] && statement.
-####  * Note: [[ -n $something ]] - double brackets does not require quotes for variables: ie, "$something".
-####  * Always use quotes, double or single, for all string values.
-####  * All new code/methods must be in a function.
-
-####  * For all boolean tests, use 'true' / 'false'.
-####    !! Do NOT use 0 or 1 unless it's a function return. 
-####  * Avoid complicated tests in the if condition itself.
-####  * To 'return' a value in a function, use 'echo <var>'.
-####  * For gawk: use always if ( num_of_cores > 1 ) { hanging { starter for all blocks
-####    This lets us use one method for all gawk structures, including BEGIN/END, if, for, etc
-####  * Using ${VAR} is about 30% slower than $VAR because bash has to check the stuff for actions
-####  SUBSHELLS ARE EXPENSIVE! - run these two if you do not believe me.
-####  time for (( i=0; i<1000; i++ )) do ff='/usr/local/bin/foo.pid';ff=${ff##*/};ff=${ff%.*};done;echo $ff
-####  time for (( i=0; i<1000; i++ )) do ff='/usr/local/bin/foo.pid';ff=$( basename $ff | cut -d '.' -f 1 );done;echo $ff
-####
-####  VARIABLE/FUNCTION NAMING:
-####  * All functions should follow standard naming--verb adjective noun. 
-####     ie, get_cpu_data
-####  * All variables MUST be initialized / declared explicitly, either top of file, for Globals, or using local
-####  * All variables should clearly explain what they are, except counters like i, j.
-####  * Each word of Bash variable must be separated by '_' (underscore) (camel form), like: cpu_data
-####  * Each word of Gawk variable must be like this (first word lower, following start with upper): cpuData
-####  * Global variables are 'UPPER CASE', at top of this file.
-####     ie, SOME_VARIABLE=''
-####  * Local variables are 'lower case' and declared at the top of the function using local, always.
-####     ie: local some_variable=''
-####  * Locals that will be inherited by child functions have first char capitalized (so you know they are inherited).
-####     ie, Some_Variable 
-####  * Booleans should start with b_ (local) or B_ (global) and state clearly what is being tested.
-####  * Arrays should start with a_ (local) or A_ (global).
-####
-####  SPECIAL NOTES:
-####  * 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
-####    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.
-####  * print_screen_output " " # requires space, not null, to avoid error in for example in irssi
-####  * For logging of array data, array must be placed into the a_temp, otherwise only the first key logs
-####  * In gawk search patterns, . is a wildcard EXCEPT in [0-9.] type containers, then it's a literal
-####    So outside of bracketed items, it must be escaped, \. but inside, no need. Outside of gawk it should 
-####    be escaped in search patterns if you are using it as a literal.
-####  
-####  PACKAGE MANAGER DATA (note, while inxi tries to avoid using package managers to get data, sometimes 
-####  it's the only way to get some data):
-####  * dpkg options: http://www.cyberciti.biz/howto/question/linux/dpkg-cheat-sheet.php
-####  * pacman options: https://wiki.archlinux.org/index.php/Pacman_Rosetta
-####
-####  As with all 'rules' there are acceptions, these are noted where used.
-###################################################################################
-####   KDE Konversation information.  Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4)
-###################################################################################
-####  * dcop and dbus  -- these talk back to Konversation from this program
-####  * Scripting info -- http://konversation.berlios.de/docs/scripting.html
-####    -- http://www.kde.org.uk/apps/konversation/
-####  * dbus info      -- http://dbus.freedesktop.org/doc/dbus-tutorial.html
-####    view dbus info -- https://fedorahosted.org/d-feet/
-####    -- or run qdbus
-####  * Konvi dbus/usage-- qdbus org.kde.konversation /irc say <server> <target-channel> <output>
-####  * Python usage   -- http://wiki.python.org/moin/DbusExamples  (just in case)
-####
-####   Because webpages come and go, the above information needs to be moved to inxi's wiki
-########################################################################
-####  Valuable Resources
-####  CPU flags: http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean
-####  Advanced Bash: http://wiki.bash-hackers.org/syntax/pe
-####  gawk arrays: http://www.math.utah.edu/docs/info/gawk_12.html
-####  raid mdstat: http://www-01.ibm.com/support/docview.wss?uid=isg3T1011259
-####               http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array
-####               https://raid.wiki.kernel.org/index.php/Mdstat
-########################################################################
-####  TESTING FLAGS
-####  inxi supports advanced testing triggers to do various things, using -! <arg>
-####  -! 1  - triggers default B_TESTING_1='true' to trigger some test or other
-####  -! 2  - triggers default B_TESTING_2='true' to trigger some test or other
-####  -! 3  - triggers B_TESTING_1='true' and B_TESTING_2='true'
-####  -! 10 - triggers an update from the primary dev download server instead of svn
-####  -! 11 - triggers an update from svn branch one - if present, of course
-####  -! 12 - triggers an update from svn branch two - if present, of course
-####  -! 13 - triggers an update from svn branch three - if present, of course
-####  -! 14 - triggers an update from svn branch four - if present, of course
-####  -! <http://......> - Triggers an update from whatever server you list.
-####  LOG FLAGS (logs to $HOME/.inxi/inxi.log with rotate 3 total)
-####  -@ 8  - Basic data logging of generated data / array values
-####  -@ 9  - Full logging of all data used, including cat of files and system data
-####  -@ 10 - Basic data logging plus color code logging
-########################################################################
-#### VARIABLES
-########################################################################
-
-## NOTE: we can use hwinfo if it's available in all systems, or most, to get
-## a lot more data and verbosity levels going
-
-### DISTRO MAINTAINER FLAGS ###
-# flag to allow distro maintainers to turn off update features. If false, turns off
-# -U and -! testing/advanced update options, as well as removing the -U help menu item
-# NOTE: Usually you want to create these in /etc/inxi.conf to avoid having to update each time
-B_ALLOW_UPDATE='true'
-B_ALLOW_WEATHER='true'
-
-### USER CONFIGS: SET IN inxi.conf file see wiki for directions ###
-# http://code.google.com/p/inxi/wiki/script_configuration_files
-# override in user config if desired, seems like less than .3 doesn't work as reliably
-CPU_SLEEP='0.3' 
-FILTER_STRING='<filter>'
-
-# for features like help/version will fit to terminal / console screen width. Console
-# widths will be dynamically set in main() based on cols in term/console
-COLS_MAX_CONSOLE='115'
-COLS_MAX_IRC='105'
-# note, this is console out of x/display server, will also be set dynamically
-# not used currently, but maybe in future
-COLS_MAX_NO_DISPLAY='140'
-PS_COUNT=5
-# change to less, or more if you have very slow connection
-DL_TIMEOUT=8
-### END USER CONFIGS ###
-
-### LOCALIZATION - DO NOT CHANGE! ###
-# set to default LANG to avoid locales errors with , or .
-LANG=C
-# Make sure every program speaks English.
-LC_ALL="C"
-export LC_ALL
-
-### ARRAYS ###
-## Prep
-# Clear nullglob, because it creates unpredictable situations with IFS=$'\n' ARR=($VAR) IFS="$ORIGINAL_IFS"
-# type constructs. Stuff like [rev a1] is now seen as a glob expansion pattern, and fails, and
-# therefore results in nothing.
-shopt -u nullglob
-## info on bash built in: $IFS - http://tldp.org/LDP/abs/html/internalvariables.html
-# Backup the current Internal Field Separator
-ORIGINAL_IFS="$IFS"
-
-## Initialize
-A_ALSA_DATA=''
-A_AUDIO_DATA=''
-A_BATTERY_DATA=''
-A_CMDL=''
-A_CPU_CORE_DATA=''
-A_CPU_DATA=''
-A_CPU_TYPE_PCNT_CCNT=''
-A_DEBUG_BUFFER=''
-A_GCC_VERSIONS=''
-A_GLX_DATA=''
-A_GRAPHICS_CARD_DATA=''
-A_GRAPHIC_DRIVERS=''
-A_HDD_DATA=''
-A_INIT_DATA=''
-A_INTERFACES_DATA=''
-A_MACHINE_DATA=''
-A_MEMORY_DATA=''
-A_NETWORK_DATA=''
-A_OPTICAL_DRIVE_DATA=''
-A_PARTITION_DATA=''
-A_PCICONF_DATA=''
-A_PS_DATA=''
-A_RAID_DATA=''
-A_SENSORS_DATA=''
-A_UNMOUNTED_PARTITION_DATA=''
-A_WEATHER_DATA=''
-A_DISPLAY_SERVER_DATA=''
-
-### BOOLEANS ###
-## standard boolean flags ##
-B_BSD_DISK_SET='false'
-B_BSD_RAID='false'
-B_COLOR_SCHEME_SET='false'
-B_CONSOLE_IRC='false'
-# triggers full display of cpu flags
-B_CPU_FLAGS_FULL='false'
-# test for dbus irc client
-B_DBUS_CLIENT='false'
-# kde dcop
-B_DCOP='false'
-# Debug flood override: make 'true' to allow long debug output
-B_DEBUG_FLOOD='false'
-# for special -i debugging cases
-B_DEBUG_I='false'
-B_DMIDECODE_SET='false'
-# show extra output data
-B_EXTRA_DATA='false'
-# triggered by -xx
-B_EXTRA_EXTRA_DATA='false'
-B_FORCE_DMIDECODE='false'
-B_ID_SET='false'
-# override certain errors due to currupted data
-B_HANDLE_CORRUPT_DATA='false'
-B_LABEL_SET='false'
-B_LSPCI='false'
-B_LOG_COLORS='false'
-B_LOG_FULL_DATA='false'
-B_MAPPER_SET='false'
-B_OUTPUT_FILTER='false'
-B_OVERRIDE_FILTER='false'
-B_PCICONF='false'
-B_PCICONF_SET='false'
-# kde qdbus
-B_QDBUS='false'
-B_PORTABLE='false'
-B_RAID_SET='false'
-B_ROOT='false'
-B_RUN_COLOR_SELECTOR='false'
-B_RUNNING_IN_DISPLAY='false' # in x type display server
-if tty >/dev/null;then
-       B_IRC='false'
-else
-       B_IRC='true'
-fi
-# this sets the debug buffer
-B_SCRIPT_UP='false'
-B_SHOW_ADVANCED_NETWORK='false'
-# Show sound card data
-B_SHOW_AUDIO='false'
-B_SHOW_BASIC_RAID='false'
-B_SHOW_BASIC_CPU='false'
-B_SHOW_BASIC_DISK='false'
-B_SHOW_BASIC_OPTICAL='false'
-B_SHOW_BATTERY='false'
-B_SHOW_BATTERY_FORCED='false'
-B_SHOW_CPU='false'
-B_SHOW_DISPLAY_DATA='false'
-B_SHOW_DISK_TOTAL='false'
-B_SHOW_DISK='false'
-# Show full hard disk output
-B_SHOW_FULL_HDD='false'
-B_SHOW_FULL_OPTICAL='false'
-B_SHOW_GRAPHICS='false'
-# Set this to 'false' to avoid printing the hostname, can be set false now
-B_SHOW_HOST='true'
-B_SHOW_INFO='false'
-B_SHOW_IP='false'
-B_SHOW_LABELS='false'
-B_SHOW_MACHINE='false'
-B_SHOW_MEMORY='false'
-B_SHOW_NETWORK='false'
-# either -v > 3 or -P will show partitions
-B_SHOW_PARTITIONS='false'
-B_SHOW_PARTITIONS_FULL='false'
-B_SHOW_PS_CPU_DATA='false'
-B_SHOW_PS_MEM_DATA='false'
-B_SHOW_RAID='false'
-# because many systems have no mdstat file, -b/-F should not show error if no raid file found
-B_SHOW_RAID_R='false' 
-B_SHOW_REPOS='false'
-B_SHOW_SENSORS='false'
-# triggers only short inxi output
-B_SHOW_SHORT_OUTPUT='false'
-B_SHOW_SYSTEM='false'
-B_SHOW_UNMOUNTED_PARTITIONS='false'
-B_SHOW_UUIDS='false'
-B_SHOW_WEATHER='false'
-B_SYSCTL='false'
-# triggers various debugging and new option testing
-B_TESTING_1='false'
-B_TESTING_2='false'
-B_UPLOAD_DEBUG_DATA='false'
-B_USB_NETWORKING='false'
-# set to true here for debug logging from script start
-B_USE_LOGGING='false'
-B_UUID_SET='false'
-B_XORG_LOG='false'
-
-## Directory/file exist flags; test as [[ $(boolean) ]] not [[ $boolean ]]
-B_ASOUND_DEVICE_FILE='false'
-B_ASOUND_VERSION_FILE='false'
-B_BASH_ARRAY='false'
-B_CPUINFO_FILE='false'
-B_DMESG_BOOT_FILE='false' # bsd only
-B_LSB_FILE='false'
-B_MDSTAT_FILE='false'
-B_MEMINFO_FILE='false'
-B_MODULES_FILE='false' #
-B_MOUNTS_FILE='false'
-B_OS_RELEASE_FILE='false' # new default distro id file? will this one work where lsb-release didn't?
-B_PARTITIONS_FILE='false' #
-B_PROC_DIR='false'
-B_SCSI_FILE='false'
-
-## app tested for and present, to avoid repeat tests
-B_FILE_TESTED='false'
-B_HDDTEMP_TESTED='false'
-B_MODINFO_TESTED='false'
-B_SUDO_TESTED='false'
-
-### CONSTANTS/INITIALIZE - SOME MAY BE RESET LATER ###
-DCOPOBJ="default"
-DEBUG=0 # Set debug levels from 1-10 (8-10 trigger logging levels)
-# Debug Buffer Index, index into a debug buffer storing debug messages until inxi is 'all up'
-DEBUG_BUFFER_INDEX=0
-## note: the debugger rerouting to /dev/null has been moved to the end of the get_parameters function
-## so -@[number] debug levels can be set if there is a failure, otherwise you can't even see the errors
-SED_I='-i' # for gnu sed, will be set to -i '' for bsd sed
-SED_RX='-r' # for gnu sed, will be set to -E for bsd sed for backward compatibility
-
-# default to false, no konversation found, 1 is native konvi (qt3/KDE3) script mode, 2 is /cmd inxi start,
-##     3 is Konversation > 1.2 (qt4/KDE4) 
-KONVI=0
-# NO_CPU_COUNT=0       # Wether or not the string "dual" or similar is found in cpuinfo output. If so, avoid dups.
-# This is a variable that controls how many parameters inxi will parse in a /proc/<pid>/cmdline file before stopping.
-PARAMETER_LIMIT=30
-SCHEME=0 # set default scheme - do not change this, it's set dynamically
-# this is set in user prefs file, to override dynamic temp1/temp2 determination of sensors output in case
-# cpu runs colder than mobo
-SENSORS_CPU_NO=''
-# SHOW_IRC=1 to avoid showing the irc client version number, or SHOW_IRC=0 to disable client information completely.
-SHOW_IRC=2
-# Verbosity level defaults to 0, this can also be set with -v0, -v2, -v3, etc as a parameter.
-VERBOSITY_LEVEL=0
-# Supported number of verbosity levels, including 0
-VERBOSITY_LEVELS=7
-
-### LOGGING ###
-## logging eval variables, start and end function: Insert to LOGFS LOGFE when debug level >= 8
-LOGFS_STRING='log_function_data fs $FUNCNAME "$( echo $@ )"'
-LOGFE_STRING='log_function_data fe $FUNCNAME'
-LOGFS=''
-LOGFE=''
-# uncomment for debugging from script start
-# LOGFS=$LOGFS_STRING
-# LOGFE=$LOGFE_STRING
-
-### FILE NAMES/PATHS/URLS - must be non root writable ###
-# File's used when present
-FILE_ASOUND_DEVICE='/proc/asound/cards'
-FILE_ASOUND_MODULES='/proc/asound/modules' # not used but maybe for -A?
-FILE_ASOUND_VERSION='/proc/asound/version'
-FILE_CPUINFO='/proc/cpuinfo'
-FILE_DMESG_BOOT='/var/run/dmesg.boot'
-FILE_LSB_RELEASE='/etc/lsb-release'
-FILE_MDSTAT='/proc/mdstat'
-FILE_MEMINFO='/proc/meminfo'
-FILE_MODULES='/proc/modules'
-FILE_MOUNTS='/proc/mounts'
-FILE_OS_RELEASE='/etc/os-release'
-FILE_PARTITIONS='/proc/partitions'
-FILE_SCSI='/proc/scsi/scsi'
-FILE_XORG_LOG='/var/log/Xorg.0.log' # if not found, search and replace with actual location
-
-FILE_PATH=''
-HDDTEMP_PATH=''
-MODINFO_PATH=''
-SUDO_PATH=''
-
-SCRIPT_DATA_DIR="$HOME/.inxi"
-ALTERNATE_FTP='' # for data uploads
-ALTERNATE_WEATHER_LOCATION='' # weather alternate location
-LOG_FILE="$SCRIPT_DATA_DIR/inxi.log"
-LOG_FILE_1="$SCRIPT_DATA_DIR/inxi.1.log"
-LOG_FILE_2="$SCRIPT_DATA_DIR/inxi.2.log"
-MAN_FILE_DOWNLOAD='https://github.com/smxi/inxi/raw/master/inxi.1.gz'
-MAN_FILE_LOCATION='/usr/share/man/man1'
-SCRIPT_NAME='inxi'
-SCRIPT_PATCH_NUMBER=''
-SCRIPT_PATH='' #filled-in in Main
-SCRIPT_VERSION_NUMBER=""       #filled-in in Main
-SCRIPT_DOWNLOAD='https://github.com/smxi/inxi/raw/master/'
-SCRIPT_DOWNLOAD_BRANCH_1='https://github.com/smxi/inxi/raw/one/'
-SCRIPT_DOWNLOAD_BRANCH_2='https://github.com/smxi/inxi/raw/two/'
-SCRIPT_DOWNLOAD_BRANCH_3='https://github.com/smxi/inxi/raw/three/'
-SCRIPT_DOWNLOAD_BRANCH_4='https://github.com/smxi/inxi/raw/four/'
-SCRIPT_DOWNLOAD_BRANCH_BSD='https://github.com/smxi/inxi/raw/bsd/'
-SCRIPT_DOWNLOAD_BRANCH_GNUBSD='https://github.com/smxi/inxi/raw/gnubsd/'
-SCRIPT_DOWNLOAD_DEV='http://smxi.org/test/'
-# note, you can use any ip url here as long as it's the only line on the output page.
-# Also the ip address must be the last thing on that line. If you abuse this ip tool 
-# you will be banned from further access. Most > 24x daily automated queries to it are abuse.
-WAN_IP_URL='http://smxi.org/opt/ip.php'
-KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data)
-
-### INITIALIZE VARIABLES NULL ###
-BSD_TYPE=''
-BSD_VERSION=
-CMDL_MAX=''
-
-DEV_DISK_ID=''
-DEV_DISK_LABEL=''
-DEV_DISK_MAPPER=''
-DEV_DISK_UUID=''
-DMIDECODE_DATA=''
-DNSTOOL=''
-DOWNLOADER='wget'
-IRC_CLIENT=''
-IRC_CLIENT_VERSION=''
-PS_THROTTLED=''
-REPO_DATA=''
-
-### LAYOUT ###
-# These two determine separators in single line output, to force irc clients not to break off sections
-SEP1='~'
-SEP2=' '
-# these will assign a separator to non irc states. Important! Using ':' can trigger stupid emoticon
+#!/usr/bin/env perl
+## infobash: Copyright (C) 2005-2007  Michiel de Boer aka locsmif
+## inxi: Copyright (C) 2008-2018 Harald Hope
+##       Additional features (C) Scott Rogers - kde, cpu info
+## Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
+## Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
+## Jarett.Stevens - dmidecode -M patch for older systems with the /sys
+##
+## License: GNU GPL v3 or greater
+##
+## You should have received a copy of the GNU General Public License
+## 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
+
+use strict;
+use warnings;
+# use diagnostics;
+use 5.008;
+
+use Cwd qw(abs_path); # qw(abs_path);#abs_path realpath getcwd
+use Data::Dumper qw(Dumper); # print_r
+use File::Find;
+use Getopt::Long qw(GetOptions);
+# Note: default auto_abbrev is enabled, that's fine
+Getopt::Long::Configure ('bundling', 'no_ignore_case', 
+'no_getopt_compat', 'no_auto_abbrev','pass_through');
+use POSIX qw(uname strftime ttyname);
+# use feature qw(state);
+
+## INXI INFO ##
+my $self_name='inxi';
+my $self_version='3.0.18';
+my $self_date='2018-07-16';
+my $self_patch='00';
+## END INXI INFO ##
+
+### INITIALIZE VARIABLES ###
+
+## Self data
+my ($self_path, $user_config_dir, $user_config_file,$user_data_dir);
+
+## Debuggers
+my $debug=0;
+my (@t0,$end,$start,$fh_l,$log_file); # log file handle, file
+my ($b_hires,$t1,$t2,$t3) = (0,0,0,0);
+# NOTE: redhat removed HiRes from Perl Core Modules. 
+if (eval {require Time::HiRes}){
+       Time::HiRes->import('gettimeofday','tv_interval','usleep');
+       $b_hires = 1;
+}
+@t0 = eval 'Time::HiRes::gettimeofday()' if $b_hires; # let's start it right away
+## Hashes
+my ( %alerts,%client,%colors,%dl,%files,%rows,%system_files,%use );
+
+## Arrays
+# ps_aux is full output, ps_cmd is only the last 10 columns to last
+my (@app,@dmesg_boot,@dmi,@gpudata,@ifs,@ifs_bsd,@paths,@pci,@ps_aux,
+@ps_cmd,@ps_gui,@sysctl,@sysctl_battery,@sysctl_sensors,@sysctl_machine,
+@uname,@usb);
+## Disk arrays 
+my (@dm_boot_disk,@dm_boot_optical,@glabel,@gpart,@hardware_raid,@labels,
+@lsblk,@partitions,@raid,@sysctl_disks,@uuids);
+my @test = (0,0,0,0,0);
+
+## Booleans
+my ($b_admin,$b_arm,$b_console_irc,$b_debug_gz,$b_debug_timers,
+$b_display,$b_dmesg_boot_check,
+$b_dmi,$b_dmidecode_force,$b_fake_bsd,$b_fake_dboot,$b_fake_pciconf,
+$b_fake_sysctl,$b_fake_usbdevs,$b_force_display,$b_gpudata,$b_irc,
+$b_log,$b_log_colors,$b_log_full,$b_man,$b_mem,$b_mips,$b_pci,$b_pci_tool,
+$b_proc_debug,$b_ps_gui,$b_root,$b_running_in_display,$b_slot_tool,
+$b_soc_audio,$b_soc_gfx,$b_soc_net,$b_sudo,$b_sysctl,$b_usb_check,$b_wmctrl);
+## Disk checks
+my ($b_dm_boot_disk,$b_dm_boot_optical,$b_glabel,$b_hardware_raid,
+$b_label_uuid,$b_lsblk,$b_partitions,$b_raid);
+my ($b_sysctl_disk,$b_update,$b_weather) = (1,1,1);
+
+## System
+my ($bsd_type,$language,$os) = ('','','');
+my ($bits_sys,$cpu_arch);
+my ($cpu_sleep,$dl_timeout,$limit,$ps_count,$usb_level) = (0.35,4,10,5,0);
+my $sensors_cpu_nu = 0;
+my $weather_unit='mi';
+
+## Tools
+my ($display,$ftp_alt,$tty_session);
+my ($display_opt,$sudo) = ('','');
+
+## Output
+my $extra = 0;# supported values: 0-3
+my $filter_string = '<filter>';
+my $line1 = "----------------------------------------------------------------------\n";
+my $line2 = "======================================================================\n";
+my $line3 = "----------------------------------------\n";
+my ($output_file,$output_type) = ('','screen');
+my $prefix = 0; # for the primiary row hash key prefix
+
+# these will assign a separator to non irc states. Important! Using ':' can 
+# trigger stupid emoticon. Note: SEP1/SEP2 from short form not used anymore.
 # behaviors in output on IRC, so do not use those.
-SEP3_IRC=''
-SEP3_CONSOLE=':'
-SEP3='' # do not set, will be set dynamically
-LINE1='---------------------------------------------------------------------------'
-LINE2='- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
-
-# Default indentation level. NOTE: actual indent is 1 greater to allow for spacing
-INDENT=10
-
-### COLUMN WIDTHS ###
-COLS_INNER='' ## for width minus INDENT
-COLS_MAX=''
-
-# these will be set dynamically in main()
-TERM_COLUMNS=80
-TERM_LINES=100
-
-# Only for legacy user config files se we can test and convert the var name
-LINE_MAX_CONSOLE=''
-LINE_MAX_IRC=''
-
-### COLORS ###
-# Defaults to 2, make this 1 for normal, 0 for no colorcodes at all. Use following variables in config 
-# files to change defaults for each type, or global
-# Same as runtime parameter.
-DEFAULT_COLOR_SCHEME=2
-## color variables - set dynamically
-COLOR_SCHEME=''
-C1=''
-C2=''
-CN=''
-## Always leave these blank, these are only going to be set in inxi.conf files, that makes testing
-## for user changes easier after sourcing the files
-ESC='\x1b'
-GLOBAL_COLOR_SCHEME=''
-IRC_COLOR_SCHEME=''
-IRC_CONS_COLOR_SCHEME=''
-IRC_X_TERM_COLOR_SCHEME=''
-CONSOLE_COLOR_SCHEME=''
-VIRT_TERM_COLOR_SCHEME=''
-
-## Output colors
-# A more elegant way to have a scheme that doesn't print color codes (neither ANSI nor mIRC) at all. See below.
-unset EMPTY
-#             DGREY   BLACK   RED     DRED    GREEN   DGREEN  YELLOW  DYELLOW
-ANSI_COLORS="\e[1;30m \e[0;30m \e[1;31m \e[0;31m \e[1;32m \e[0;32m \e[1;33m \e[0;33m"
-IRC_COLORS="  \x0314  \x0301  \x0304  \x0305  \x0309  \x0303  \x0308  \x0307"
-#                          BLUE    DBLUE   MAGENTA DMAGENTA CYAN   DCYAN   WHITE   GREY    NORMAL
-ANSI_COLORS="$ANSI_COLORS \e[1;34m \e[0;34m \e[1;35m \e[0;35m \e[1;36m \e[0;36m \e[1;37m \e[0;37m \e[0;37m"
-IRC_COLORS=" $IRC_COLORS    \x0312 \x0302  \x0313  \x0306  \x0311  \x0310  \x0300  \x0315  \x03"
-
-#ANSI_COLORS=($ANSI_COLORS); IRC_COLORS=($IRC_COLORS)
-A_COLORS_AVAILABLE=( DGREY BLACK RED DRED GREEN DGREEN YELLOW DYELLOW BLUE DBLUE MAGENTA DMAGENTA CYAN DCYAN WHITE GREY NORMAL )
-
-# See above for notes on EMPTY
-## note: group 1: 0, 1 are null/normal
-## Following: group 2: generic, light/dark or dark/light; group 3: dark on light; group 4 light on dark; 
-# this is the count of the first two groups, starting at zero
-SAFE_COLOR_COUNT=12
-A_COLOR_SCHEMES=( 
-EMPTY,EMPTY,EMPTY 
-NORMAL,NORMAL,NORMAL 
-
-BLUE,NORMAL,NORMAL
-BLUE,RED,NORMAL 
-CYAN,BLUE,NORMAL 
-DCYAN,NORMAL,NORMAL
-DCYAN,BLUE,NORMAL 
-DGREEN,NORMAL,NORMAL 
-DYELLOW,NORMAL,NORMAL 
-GREEN,DGREEN,NORMAL 
-GREEN,NORMAL,NORMAL 
-MAGENTA,NORMAL,NORMAL
-RED,NORMAL,NORMAL
-
-BLACK,DGREY,NORMAL
-DBLUE,DGREY,NORMAL 
-DBLUE,DMAGENTA,NORMAL
-DBLUE,DRED,NORMAL 
-DBLUE,BLACK,NORMAL
-DGREEN,DYELLOW,NORMAL 
-DYELLOW,BLACK,NORMAL
-DMAGENTA,BLACK,NORMAL
-DCYAN,DBLUE,NORMAL
-
-WHITE,GREY,NORMAL
-GREY,WHITE,NORMAL
-CYAN,GREY,NORMAL 
-GREEN,WHITE,NORMAL 
-GREEN,YELLOW,NORMAL 
-YELLOW,WHITE,NORMAL 
-MAGENTA,CYAN,NORMAL 
-MAGENTA,YELLOW,NORMAL
-RED,CYAN,NORMAL
-RED,WHITE,NORMAL 
-BLUE,WHITE,NORMAL
-
-RED,BLUE,NORMAL 
-RED,DBLUE,NORMAL
-BLACK,BLUE,NORMAL
-BLACK,DBLUE,NORMAL
-NORMAL,BLUE,NORMAL
-BLUE,MAGENTA,NORMAL
-DBLUE,MAGENTA,NORMAL
-BLACK,MAGENTA,NORMAL
-MAGENTA,BLUE,NORMAL
-MAGENTA,DBLUE,NORMAL
-)
-
-#echo ${#A_COLOR_SCHEMES[@]};exit
-
-# WARNING: In the main part below (search for 'KONVI')
-# there's a check for Konversation-specific config files.
-# Any one of these can override the above if inxi is run
-# from Konversation!
-
-## DISTRO DATA/ID ##
-# 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)
-DISTROS_DERIVED="antix-version aptosid-version kanotix-version knoppix-version mandrake-release pardus-release porteus-version sabayon-release siduction-version sidux-version slitaz-release solusos-release turbolinux-release zenwalk-version"
-# debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu.
-DISTROS_EXCLUDE_LIST="debian_version devuan_version ubuntu_version"
-DISTROS_PRIMARY="arch-release gentoo-release redhat-release slackware-version SuSE-release"
-DISTROS_LSB_GOOD="mandrake-release mandriva-release mandrakelinux-release"
-# this is being used both by core distros and derived distros now, eg, solusos 1 uses it for solusos id, while
-# debian, solusos base, uses it as well, so we have to know which it is.
-DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release "
-## Distros with known problems
-# DSL (Bash 2.05b: grep -m doesn't work; arrays won't work) --> unusable output
-# Puppy Linux 4.1.2 (Bash 3.0: arrays won't work) --> works partially
-
-## OUTPUT FILTERS/SEARCH ##
-# Note that \<ltd\> bans only words, not parts of strings; in \<corp\> you can't use punctuation characters like . or ,
-# we're saving about 10+% of the total script exec time by hand building the ban lists here, using hard quotes.
-
-BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\<ltd\>|inc\.|\<inc\>|intl\.|co\.|\<co\>|corp\.|\<corp\>|\(tm\)|\(r\)|®|\(rev ..\)'
-BAN_LIST_CPU='@||cpu |cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]'
-# See github issue 75 for more details on value: *, triggers weird behaviors if present in value
-# /sys/devices/virtual/dmi/id/product_name:['*']
-# this is for bash arrays AND avoiding * in arrays: ( fred * greg ) expands to the contents of the directory
-BAN_LIST_ARRAY=',|\*'
-
-SENSORS_GPU_SEARCH='amdgpu|intel|radeon|nouveau'
-
-### USB networking search string data, because some brands can have other products than
-### wifi/nic cards, they need further identifiers, with wildcards.
-### putting the most common and likely first, then the less common, then some specifics
-USB_NETWORK_SEARCH="Wi-Fi.*Adapter|Wireless.*Adapter|Ethernet.*Adapter|WLAN.*Adapter|Network.*Adapter|802\.11|Atheros|Atmel|D-Link.*Adapter|D-Link.*Wireless|Linksys|Netgea|Ralink|Realtek.*Network|Realtek.*Wireless|Realtek.*WLAN|Belkin.*Wireless|Belkin.*WLAN|Belkin.*Network"
-USB_NETWORK_SEARCH="$USB_NETWORK_SEARCH|Actiontec.*Wireless|Actiontec.*Network|AirLink.*Wireless|Asus.*Network|Asus.*Wireless|Buffalo.*Wireless|Davicom|DWA-.*RangeBooster|DWA-.*Wireless|ENUWI-.*Wireless|LG.*Wi-Fi|Rosewill.*Wireless|RNX-.*Wireless|Samsung.*LinkStick|Samsung.*Wireless|Sony.*Wireless|TEW-.*Wireless|TP-Link.*Wireless|WG[0-9][0-9][0-9].*Wireless|WNA[0-9][0-9][0-9]|WNDA[0-9][0-9][0-9]|Zonet.*ZEW.*Wireless|54 Mbps" 
-# then a few known hard to ID ones added 
-# belkin=050d; d-link=07d1; netgear=0846; ralink=148f; realtek=0bda; 
-USB_NETWORK_SEARCH="$USB_NETWORK_SEARCH|050d:935b|0bda:8189|0bda:8197"
+my %sep = ( 
+'s1-irc' => ':',
+'s1-console' => ':',
+'s2-irc' => '',
+'s2-console' => ':',
+);
+
+my %show = ('host' => 1);
+
+my %size = (
+'console' => 115,
+# Default indentation level. NOTE: actual indent is 1 greater to allow for 
+# spacing
+'indent' => 11,
+'indent-min' => 90,
+'irc' => 100, # shorter because IRC clients have nick  lists etc
+'max' => 0,
+'no-display' => 130,
+# these will be set dynamically in set_display_width()
+'term' => 80,
+'term-lines' => 100,
+);
+
+## debug temp tools
+$client{'test-konvi'} = 0;
 
 ########################################################################
-#### MAIN: Where it all begins
+#### STARTUP
 ########################################################################
-main()
-{
-       eval $LOGFS
-       
-       local color_scheme='' kde_config_app=''
-       # this will be used by all functions following
-       local Ps_aux_Data="$( ps aux )"
-
-       # This function just initializes variables
-       initialize_data
-       
-       # Source global config overrides, needs to be here because some things
-       # can be reset that were set in initialize, but check_required_apps needs
-       if [[ -s /etc/$SCRIPT_NAME.conf ]];then
-               source /etc/$SCRIPT_NAME.conf
-       fi
-       # Source user config variables override /etc/inxi.conf variables
-       if [[ -s $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then
-               source $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf
-       fi
-       set_display_width 'live' # can be reset with -y
-       
-       # echo SCHEME $SCHEME
-       # echo B_IRC $B_IRC
-       # echo sep3: $SEP3
-       # Check for dependencies BEFORE running ANYTHING else except above functions
-       # Not all distro's have these depends installed by default. Don't want to run
-       # this if the user is requesting to see this information in the first place
-       # Only continue if required apps tests ok
-       if [[ $1 != '--recommends' ]];then
-               check_required_apps
-               check_recommended_apps
-       fi
-
-       SCRIPT_VERSION_NUMBER=$( parse_version_data 'main' )
-       SCRIPT_PATCH_NUMBER=$( parse_version_data 'patch' )
-       
-       # previous source location, check for bugs
-
-       ## this needs to run before the KONVI stuff is set below
-       ## Konversation 1.2 apparently does not like the $PPID test in get_start_client
-       ## So far there is no known way to detect if qt4_konvi is the parent process
-       ## this method will infer qt4_konvi as parent
-       get_start_client
-
-       # note: this only works if it's run from inside konversation as a script builtin or something
-       # only do this if inxi has been started as a konversation script, otherwise bypass this 
-       #       KONVI=3 ## for testing puroses
-       if [[ $KONVI -eq 1 || $KONVI -eq 3 ]];then
-               if [[ $KONVI -eq 1 ]]; then ## dcop Konversation (ie 1.x < 1.2(qt3))    
-                       DCPORT="$1"
-                       DCSERVER="$2"
-                       DCTARGET="$3"
-                       shift 3
-               elif [[ $KONVI -eq 3 ]]; then ## dbus Konversation (> 1.2 (qt4))
-                       DCSERVER="$1" ##dbus testing
-                       DCTARGET="$2" ##dbus testing
-                       shift 2
-               fi
-               # always have the current stable kde version tested first, 
-               # then use fallbacks and future proofing
-               if type -p kde4-config &>/dev/null;then
-                       kde_config_app='kde4-config'
-               elif type -p kde5-config &>/dev/null;then
-                       kde_config_app='kde5-config'
-               elif type -p kde-config &>/dev/null;then
-                       kde_config_app='kde-config'
-               fi
-               # The section below is on request of Argonel from the Konversation developer team:
-               # it sources config files like $HOME/.kde/share/apps/konversation/scripts/inxi.conf
-               if [[ -n $kde_config_app ]];then
-                       IFS=":"
-                       for kde_config in $( $kde_config_app --path data )
-                       do
-                               if [[ -r $kde_config$KONVI_CFG ]];then
-                                       source "$kde_config$KONVI_CFG"
-                                       break
-                               fi
-                       done
-                       IFS="$ORIGINAL_IFS"
-               fi
-       fi
-
-       ## leave this for debugging dcop stuff if we get that working
-       #       print_screen_output "DCPORT: $DCPORT"
-       #       print_screen_output "DCSERVER: $DCSERVER"
-       #       print_screen_output "DCTARGET: $DCTARGET"
-       
-       # first init function must be set first for colors etc. Remember, no debugger
-       # stuff works on this function unless you set the debugging flag manually.
-       # Debugging flag -@ [number] will not work until get_parameters runs.
-       
-       # "$@" passes every parameter separately quoted, "$*" passes all parameters as one quoted parameter.
-       # must be here to allow debugger and other flags to be set.
-       get_parameters "$@"
-
-       # If no colorscheme was set in the parameter handling routine, then set the default scheme
-       if [[ $B_COLOR_SCHEME_SET != 'true' ]];then
-               # This let's user pick their color scheme. For IRC, only shows the color schemes, no interactive
-               # The override value only will be placed in user config files. /etc/inxi.conf can also override
-               if [[ $B_RUN_COLOR_SELECTOR == 'true' ]];then 
-                       select_default_color_scheme
-               else
-                       # set the default, then override as required
-                       color_scheme=$DEFAULT_COLOR_SCHEME
-                       if [[ -n $GLOBAL_COLOR_SCHEME ]];then
-                               color_scheme=$GLOBAL_COLOR_SCHEME
-                       else
-                               if [[ $B_IRC == 'false' ]];then
-                                       if [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then
-                                               color_scheme=$CONSOLE_COLOR_SCHEME
-                                       elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then
-                                               color_scheme=$VIRT_TERM_COLOR_SCHEME
-                                       fi
-                               else
-                                       if [[ -n $IRC_X_TERM_COLOR_SCHEME && $B_CONSOLE_IRC == 'true' && -n $B_RUNNING_IN_DISPLAY ]];then
-                                               color_scheme=$IRC_X_TERM_COLOR_SCHEME
-                                       elif [[ -n $IRC_CONS_COLOR_SCHEME && -z $DISPLAY ]];then
-                                               color_scheme=$IRC_CONS_COLOR_SCHEME
-                                       elif [[ -n $IRC_COLOR_SCHEME ]];then
-                                               color_scheme=$IRC_COLOR_SCHEME
-                                       fi
-                               fi
-                       fi
-                       set_color_scheme $color_scheme
-               fi
-       fi
-       if [[ $B_IRC == 'false' ]];then
-               SEP3=$SEP3_CONSOLE
-       else
-               # too hard to read if no colors, so force that for users on irc
-               if [[ $SCHEME == 0 ]];then
-                       SEP3=$SEP3_CONSOLE
-               else
-                       SEP3=$SEP3_IRC
-               fi
-       fi
-       
-       # all the pre-start stuff is in place now
-       B_SCRIPT_UP='true'
-       script_debugger "Debugger: $SCRIPT_NAME is up and running..."
-       
-       # then create the output
-       print_it_out
-
-       eval $LOGFE
-       # weechat's executor plugin forced me to do this, and rightfully so, because else the exit code
-       # from the last command is taken..
-       exit 0
-}
 
 #### -------------------------------------------------------------------
-#### basic tests: set script data, booleans, PATH, version numbers
+#### MAIN
 #### -------------------------------------------------------------------
 
-# Set PATH data so we can access all programs as user. Set BAN lists.
-# initialize some boleans, these directories are used throughout the script
-# some apps are used for extended functions any directory used, should be
-# checked here first.
-# No args taken.
-initialize_data()
-{
-       eval $LOGFS
-       BSD_VERSION=$( uname -s 2>/dev/null | tr '[A-Z]' '[a-z]' )
-       # note: archbsd says they are a freebsd distro, so assuming it's the same as freebsd
-       if [[ -z ${BSD_VERSION/*bsd*/} || -z ${BSD_VERSION/*dragonfly*/} || -z ${BSD_VERSION/*darwin*/} ]];then
-               if [[ -z ${BSD_VERSION/*openbsd*/} ]];then
-                       BSD_VERSION='openbsd'
-               elif [[ -z ${BSD_VERSION/*darwin*/} ]];then
-                       BSD_VERSION='darwin'
-               fi
-               # GNU/kfreebsd will by definition have GNU tools like sed/grep
-               if [[ -z ${BSD_VERSION/*kfreebsd*/} ]];then
-                       BSD_TYPE='debian-bsd' # debian gnu bsd
-               else
-                       BSD_TYPE='bsd' # all other bsds
-                       SED_I="-i ''"
-                       SED_RX='-E'
-                       ESC=$(echo | tr '\n' '\033')
-               fi
-       fi
-       # now set the script BOOLEANS for files required to run features
-       # note that freebsd has /proc but it's empty
-       if [[ -d "/proc/" && -z $BSD_TYPE ]];then
-               B_PROC_DIR='true'
-       elif [[ -n $BSD_TYPE ]];then
-               B_PROC_DIR='false'
-       else
-               error_handler 6
-       fi
-       
-       initialize_paths
-       
-       if type -p dig &>/dev/null;then
-               DNSTOOL='dig'
-       fi
-       
-       # set downloaders. 
-       if ! type -p wget &>/dev/null;then
-               # first check for bsd stuff
-               if type -p fetch &>/dev/null;then
-                       DOWNLOADER='fetch'
-               elif type -p curl &>/dev/null;then
-                       DOWNLOADER='curl'
-               elif [[ $BSD_VERSION == 'openbsd' && -n $( type -p ftp ) ]];then
-                       DOWNLOADER='ftp'
-               else
-                       DOWNLOADER='no-downloader'
-               fi
-       fi
-       
-       if [[ -n $BSD_TYPE ]];then
-               if [[ -e $FILE_DMESG_BOOT ]];then
-                       B_DMESG_BOOT_FILE='true'
-               fi
-       else
-               # found a case of battery existing but having nothing in it on desktop mobo
-               # not all laptops show the first. /proc/acpi/battery is deprecated.
-               if [[ -n $( ls /proc/acpi/battery 2>/dev/null ) || -n $( ls /sys/class/power_supply/ 2>/dev/null )  ]];then
-                       B_PORTABLE='true'
-               fi
-       fi
-       if [[ -e $FILE_CPUINFO ]]; then
-               B_CPUINFO_FILE='true'
-       fi
-       if [[ -e $FILE_MEMINFO ]];then
-               B_MEMINFO_FILE='true'
-       fi
-       if [[ -e $FILE_ASOUND_DEVICE ]];then
-               B_ASOUND_DEVICE_FILE='true'
-       fi
-       if [[ -e $FILE_ASOUND_VERSION ]];then
-               B_ASOUND_VERSION_FILE='true'
-       fi
-       if [[ -f $FILE_LSB_RELEASE ]];then
-               B_LSB_FILE='true'
-       fi
-       if [[ -f $FILE_OS_RELEASE ]];then
-               B_OS_RELEASE_FILE='true'
-       fi
-       if [[ -e $FILE_SCSI ]];then
-               B_SCSI_FILE='true'
-       fi
-       if [[ -n $DISPLAY ]];then
-               B_SHOW_DISPLAY_DATA='true'
-               B_RUNNING_IN_DISPLAY='true'
-       fi
-       if [[ -e $FILE_MDSTAT ]];then
-               B_MDSTAT_FILE='true'
-       fi
-       if [[ -e $FILE_MODULES ]];then
-               B_MODULES_FILE='true'
-       fi
-       if [[ -e $FILE_MOUNTS ]];then
-               B_MOUNTS_FILE='true'
-       fi
-       if [[ -e $FILE_PARTITIONS ]];then
-               B_PARTITIONS_FILE='true'
-       fi
-       # default to the normal location, then search for it
-       if [[ -e $FILE_XORG_LOG ]];then
-               B_XORG_LOG='true'
-       else
-               # Detect location of the Xorg log file
-               if type -p xset &>/dev/null; then
-                       FILE_XORG_LOG=$( xset q 2>/dev/null | grep -i 'Log file' | gawk '{print $3}')
-                       if [[ -e $FILE_XORG_LOG ]];then
-                               B_XORG_LOG='true'
-                       fi
-               fi
-       fi
-       # gfx output will require this flag
-       if [[ $( whoami ) == 'root' ]];then
-               B_ROOT='true'
-       fi
-       eval $LOGFE
-}
-
-# args: $1 - default OR override default cols max integer count
-set_display_width()
-{
-       local cols_max_override=$1
-       
-       if [[ $cols_max_override == 'live' ]];then
-               ## sometimes tput will trigger an error (mageia) if irc client
-               if [[ $B_IRC == 'false' ]];then
-                       if type -p tput &>/dev/null;then
-                               TERM_COLUMNS=$(tput cols)
-                               TERM_LINES=$(tput lines)
-                       fi
-                       # double check, just in case it's missing functionality or whatever
-                       if [[ -z $TERM_COLUMNS || -n ${TERM_COLUMNS//[0-9]/} ]];then
-                               TERM_COLUMNS=80
-                               TERM_LINES=100
-                       fi
-               fi
-               # Convert to new variable names if set in config files, legacy test
-               if [[ -n $LINE_MAX_CONSOLE ]];then
-                       COLS_MAX_CONSOLE=$LINE_MAX_CONSOLE
-               fi
-               if [[ -n $LINE_MAX_IRC ]];then
-                       COLS_MAX_IRC=$LINE_MAX_IRC
-               fi
-               # this lets you set different widths for in or out of display server
-       #       if [[ $B_RUNNING_IN_DISPLAY == 'false' && -n $COLS_MAX_NO_DISPLAY ]];then
-       #               COLS_MAX_CONSOLE=$COLS_MAX_NO_DISPLAY
-       #       fi
-               # TERM_COLUMNS is set in top globals, using tput cols
-               # echo tc: $TERM_COLUMNS cmc: $COLS_MAX_CONSOLE
-               if [[ $TERM_COLUMNS -lt $COLS_MAX_CONSOLE ]];then
-                       COLS_MAX_CONSOLE=$TERM_COLUMNS
-               fi
-               # adjust, some terminals will wrap if output cols == term cols
-               COLS_MAX_CONSOLE=$(( $COLS_MAX_CONSOLE - 2 ))
-               # echo cmc: $COLS_MAX_CONSOLE
-               # comes after source for user set stuff
-               if [[ $B_IRC == 'false' ]];then
-                       COLS_MAX=$COLS_MAX_CONSOLE
-               else
-                       COLS_MAX=$COLS_MAX_IRC
-               fi
-       else
-               COLS_MAX=$cols_max_override
-       fi
-       COLS_INNER=$(( $COLS_MAX - $INDENT - 1 ))
-       # echo cm: $COLS_MAX ci: $COLS_INNER
-}
-
-# arg: $1 - version number: main/patch/date
-parse_version_data()
-{
-       local version_data=''
-
-       # note, using ####[[:space:]]+ to avoid having this function also trip the version datas
-       case $1 in
-               date)
-                       version_data=$( gawk -F ': ' '
-                       /####[[:space:]]+Date:/ {
-                               print $NF
-                       }' "$SCRIPT_PATH/$SCRIPT_NAME" )
-                       ;;
-               main)
-                       version_data=$( gawk '
-                       /####[[:space:]]+Version:/ {
-                               print $3
-                       }' "$SCRIPT_PATH/$SCRIPT_NAME" )
-                       ;;
-               patch)
-                       version_data=$( gawk '
-                       /####[[:space:]]+Patch Number:/ {
-                               print $4
-                       }' "$SCRIPT_PATH/$SCRIPT_NAME" )
-                       ;;
-       esac
-       echo $version_data
-}
-
-initialize_paths()
-{
-       local path='' added_path='' b_path_found='' sys_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:/opt/local/bin"
-       
-       # this needs to be set here because various options call the parent initialize function directly.
-       SCRIPT_PATH=$( dirname "$0" )
-
-       # Fallback paths put into $extra_paths; This might, among others, help on gentoo.
-       # Now, create a difference of $PATH and $extra_paths and add that to $PATH:
-       IFS=":"
-       for path in $extra_paths
-       do
-               b_path_found='false'
-               for sys_path in $PATH
-               do
-                       if [[ $path == $sys_path ]];then
-                               b_path_found='true'
-                       fi
-               done
-               if [[ $b_path_found == 'false' ]];then
-                       added_path="$added_path:$path"
-               fi
-       done
-
-       IFS="$ORIGINAL_IFS"
-       PATH="$PATH$added_path"
-       # echo "PATH='$PATH'"
-       ##/bin/sh -c 'echo "PATH in subshell=\"$PATH\""'
-}
-# No args taken.
-check_recommended_apps()
-{
-       eval $LOGFS
-       local bash_array_test=( "one" "two" )
-
-       # check for array ability of bash, this is only good for the warning at this time
-       # the boolean could be used later
-       # bash version 2.05b is used in DSL
-       # bash version 3.0 is used in Puppy Linux; it has a known array bug <reference to be placed here>
-       # versions older than 3.1 don't handle arrays
-       # distro's using below 2.05b are unknown, released in 2002
-       if [[ ${bash_array_test[1]} -eq "two" ]];then
-               B_BASH_ARRAY='true'
-       else
-               script_debugger "Suggestion: update to Bash v3.1 for optimal inxi output"
-       fi
-       # test for a few apps that bsds may not have after initial tests
-       if type -p lspci &>/dev/null;then
-               B_LSPCI='true'
-       fi
-       if [[ -n $BSD_TYPE ]];then
-               if type -p sysctl &>/dev/null;then
-                       B_SYSCTL='true'
-               fi
-               if type -p pciconf &>/dev/null;then
-                       B_PCICONF='true'
-               fi
-       fi
-       # now setting qdbus/dcop for first run, some systems can have both by the way
-       if type -p qdbus &>/dev/null;then
-               B_QDBUS='true'
-       fi
-       if type -p dcop &>/dev/null;then
-               B_DCOP='true'
-       fi
-       eval $LOGFE
-}
-
-# Determine if any of the absolutely necessary tools are absent
-# No args taken.
-check_required_apps()
-{
-       eval $LOGFS
-       local app_name=''
-       # bc removed from deps for now
-       local depends="df gawk grep ps readlink tr uname wc"
-       
-       if [[ -z $BSD_TYPE  ]];then
-               depends="$depends lspci"
-       elif [[ $BSD_TYPE == 'bsd' ]];then
-               depends="$depends sysctl"
-               # debian-bsd has lspci but you must be root to run it
-       elif [[ $BSD_TYPE == 'debian-bsd' ]];then
-               depends="$depends sysctl lspci"
-       fi
-       # no need to add xprop because it will just give N/A if not there, but if we expand use of xprop,
-       # should add that here as a test, then use the B_SHOW_DISPLAY_DATA flag to trigger the tests in de function
-       local x_apps="xrandr xdpyinfo glxinfo" 
-
-       if [[ $B_RUNNING_IN_DISPLAY == 'true' ]];then
-               for app_name in $x_apps
-               do
-                       if ! type -p $app_name &>/dev/null;then
-                               script_debugger "Resuming in non X mode: $app_name not found. For package install advice run: $SCRIPT_NAME --recommends"
-                               B_SHOW_DISPLAY_DATA='false'
-                               break
-                       fi
-               done
-       fi
-
-       app_name=''
-
-       for app_name in $depends
-       do
-               if ! type -p $app_name &>/dev/null;then
-                       error_handler 5 "$app_name"
-               fi
-       done
-       eval $LOGFE
-}
-
-## note: this is now running inside each gawk sequence directly to avoid exiting gawk
-## looping in bash through arrays, then re-entering gawk to clean up, then writing back to array
-## in bash. For now I'll leave this here because there's still some interesting stuff to get re methods
-# Enforce boilerplate and buzzword filters
-# args: $1 - BAN_LIST_NORMAL/BAN_LIST_CPU; $2 - string to sanitize
-sanitize_characters()
-{
-       eval $LOGFS
-       # Cannot use strong quotes to unquote a string with pipes in it!
-       # bash will interpret the |'s as usual and try to run a subshell!
-       # Using weak quotes instead, or use '"..."'
-       echo "$2" | gawk "
-       BEGIN {
-               IGNORECASE=1
-       }
-       {
-               gsub(/${!1}/,\"\")
-               gsub(/ [ ]+/,\" \")    ## ([ ]+) with (space)
-               gsub(/^ +| +$/,\"\")   ## (pipe char) with (nothing)
-               print                  ## prints (returns) cleaned input
-       }"
-       eval $LOGFE
-}
-
-# Set the colorscheme
-# args: $1 = <scheme number>|<"none">
-set_color_scheme()
-{
-       eval $LOGFS
-       local i='' a_output_colors='' a_color_codes=''
-
-       if [[ $1 -ge ${#A_COLOR_SCHEMES[@]} ]];then
-               set -- 1
-       fi
-       # Set a global variable to allow checking for chosen scheme later
-       SCHEME="$1"
-       if [[ $B_IRC == 'false' ]];then
-               a_color_codes=( $ANSI_COLORS )
-       else
-               a_color_codes=( $IRC_COLORS )
-       fi
-       for (( i=0; i < ${#A_COLORS_AVAILABLE[@]}; i++ ))
-       do
-               eval "${A_COLORS_AVAILABLE[i]}=\"${a_color_codes[i]}\""
-       done
-       IFS=","
-       a_output_colors=( ${A_COLOR_SCHEMES[$1]} )
-       IFS="$ORIGINAL_IFS"
-       # then assign the colors globally
-       C1="${!a_output_colors[0]}"
-       C2="${!a_output_colors[1]}"
-       CN="${!a_output_colors[2]}"
-       # ((COLOR_SCHEME++)) ## note: why is this? ##
-       # handle some explicit colors that are used for no color 0
-       if [[ $SCHEME -eq 0 ]];then
-               NORMAL=''
-               RED=''
-       fi
-       eval $LOGFE
-}
-
-select_default_color_scheme()
-{
-       eval $LOGFS
-       local spacer='  ' options='' user_selection='' config_variable=''
-       local config_file="$HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf"
-       local irc_clear="\e[0m" 
-       local irc_gui='Unset' irc_console='Unset' irc_x_term='Unset'
-       local console='Unset' virt_term='Unset' global='Unset' 
-       
-       if [[ -n $IRC_COLOR_SCHEME ]];then
-               irc_gui="Set: $IRC_COLOR_SCHEME"
-       fi
-       if [[ -n $IRC_CONS_COLOR_SCHEME ]];then
-               irc_console="Set: $IRC_CONS_COLOR_SCHEME"
-       fi
-       if [[ -n $IRC_X_TERM_COLOR_SCHEME ]];then
-               irc_x_term="Set: $IRC_X_TERM_COLOR_SCHEME"
-       fi
-       if [[ -n $VIRT_TERM_COLOR_SCHEME ]];then
-               virt_term="Set: $VIRT_TERM_COLOR_SCHEME"
-       fi
-       if [[ -n $CONSOLE_COLOR_SCHEME ]];then
-               console="Set: $CONSOLE_COLOR_SCHEME"
-       fi
-       if [[ -n $GLOBAL_COLOR_SCHEME ]];then
-               global="Set: $GLOBAL_COLOR_SCHEME"
-       fi
-       
-       # don't want these printing in irc since they show literally
-       if [[ $B_IRC == 'true' ]];then
-               irc_clear=''
-       fi
-       # first make output neutral so it's just plain default for console client
-       set_color_scheme "0"
-       # print_lines_basic "0" "" ""
-       if [[ $B_IRC == 'false' ]];then
-               print_lines_basic "0" "" "Welcome to $SCRIPT_NAME! Please select the default $COLOR_SELECTION color scheme."
-               # print_screen_output "You will see this message only one time per user account, unless you set preferences in: /etc/$SCRIPT_NAME.conf"
-               print_screen_output " "
-       fi
-       print_lines_basic "0" "" "Because there is no way to know your $COLOR_SELECTION foreground/background colors, you can set your color preferences from color scheme option list below. 0 is no colors, 1 neutral. After these, there are 4 sets: 1-dark or light backgrounds; 2-light backgrounds; 3-dark backgrounds; 4-miscellaneous."
-       if [[ $B_IRC == 'false' ]];then
-               print_lines_basic "0" "" "Please note that this will set the $COLOR_SELECTION preferences only for user: $(whoami)"
-       fi
-       print_screen_output "$LINE1"
-       for (( i=0; i < ${#A_COLOR_SCHEMES[@]}; i++ ))
-       do
-               if [[ $i -gt 9 ]];then
-                       spacer=' '
-               fi
-               # only offer the safe universal defaults
-               case $COLOR_SELECTION in
-                       global|irc|irc-console|irc-virtual-terminal)
-                               if [[ $i -gt $SAFE_COLOR_COUNT ]];then
-                                       break
-                               fi
-                               ;;
-               esac
-               set_color_scheme $i
-               print_screen_output "$irc_clear $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}X.Org${C2} 1.7.7"
-       done
-       set_color_scheme 0
-       
-       if [[ $B_IRC == 'false' ]];then
-               echo -n "\e[0m"
-               
-               print_screen_output "$irc_clear $i)${spacer}Remove all color settings. Restore $SCRIPT_NAME default."
-               print_screen_output "$irc_clear $(($i+1)))${spacer}Continue, no changes or config file setting."
-               print_screen_output "$irc_clear $(($i+2)))${spacer}Exit, use another terminal, or set manually."
-               print_screen_output "$LINE1"
-               print_lines_basic "0" "" "Simply type the number for the color scheme that looks best to your eyes for your $COLOR_SELECTION settings and hit ENTER. NOTE: You can bring this option list up by starting $SCRIPT_NAME with option: -c plus one of these numbers:"
-               print_lines_basic "0" "" "94^(console,^no X^-^$console); 95^(terminal,^X^-^$virt_term); 96^(irc,^gui,^X^-^$irc_gui); 97^(irc,^X,^in^terminal^-^$irc_x_term); 98^(irc,^no^X^-^$irc_console); 99^(global^-^$global)"
-               print_lines_basic "0" "" ""
-               print_screen_output "Your selection(s) will be stored here: $config_file"
-               print_lines_basic "0" "" "Global overrides all individual color schemes. Individual schemes remove the global setting."
-               print_screen_output "$LINE1"
-               read user_selection
-               if [[ "$user_selection" =~ ^([0-9]+)$ && $user_selection -lt $i ]];then
-                       case $COLOR_SELECTION in
-                               irc)
-                                       config_variable='IRC_COLOR_SCHEME'
-                                       ;;
-                               irc-console)
-                                       config_variable='IRC_CONS_COLOR_SCHEME'
-                                       ;;
-                               irc-virtual-terminal)
-                                       config_variable='IRC_X_TERM_COLOR_SCHEME'
-                                       ;;
-                               console)
-                                       config_variable='CONSOLE_COLOR_SCHEME'
-                                       ;;
-                               virtual-terminal)
-                                       config_variable='VIRT_TERM_COLOR_SCHEME'
-                                       ;;
-                               global)
-                                       config_variable='GLOBAL_COLOR_SCHEME'
-                                       ;;
-                       esac
-                       set_color_scheme $user_selection
-                       # make file/directory first if missing
-                       if [[ ! -f $config_file ]];then
-                               if [[ ! -d $HOME/.$SCRIPT_NAME ]];then
-                                       mkdir $HOME/.$SCRIPT_NAME
-                               fi
-                               touch $config_file
-                       fi
-                       if [[ -z $( grep -s "$config_variable=" $config_file ) ]];then
-                               print_lines_basic "0" "" "Creating and updating config file for $COLOR_SELECTION color scheme now..."
-                               echo "$config_variable=$user_selection" >> $config_file
-                       else
-                               print_screen_output "Updating config file for $COLOR_SELECTION color scheme now..."
-                               sed $SED_I "s/$config_variable=.*/$config_variable=$user_selection/" $config_file
-                       fi
-                       # file exists now so we can go on to cleanup
-                       case $COLOR_SELECTION in
-                               irc|irc-console|irc-virtual-terminal|console|virtual-terminal)
-                                       sed $SED_I '/GLOBAL_COLOR_SCHEME=/d' $config_file
-                                       ;;
-                               global)
-                                       sed $SED_I -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' -e '/IRC_COLOR_SCHEME=/d' \
-                                       -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file
-                                       ;;
-                       esac
-               elif [[ $user_selection == $i ]];then
-                       print_screen_output "Removing all color settings from config file now..."
-                       sed $SED_I -e '/VIRT_TERM_COLOR_SCHEME=/d' -e '/GLOBAL_COLOR_SCHEME=/d' -e '/CONSOLE_COLOR_SCHEME=/d' \
-                       -e '/IRC_COLOR_SCHEME=/d' -e '/IRC_CONS_COLOR_SCHEME=/d' -e '/IRC_X_TERM_COLOR_SCHEME=/d' $config_file
-                       set_color_scheme $DEFAULT_COLOR_SCHEME
-               elif [[ $user_selection == $(( $i+1 )) ]];then
-                       print_lines_basic "0" "" "Ok, continuing $SCRIPT_NAME unchanged. You can set the colors anytime by starting with: -c 95 to 99"
-                       if [[ -n $CONSOLE_COLOR_SCHEME && -z $DISPLAY ]];then
-                               set_color_scheme $CONSOLE_COLOR_SCHEME
-                       elif [[ -n $VIRT_TERM_COLOR_SCHEME ]];then
-                               set_color_scheme $VIRT_TERM_COLOR_SCHEME
-                       else
-                               set_color_scheme $DEFAULT_COLOR_SCHEME
-                       fi
-               elif [[ $user_selection == $(( $i+2 )) ]];then
-                       set_color_scheme $DEFAULT_COLOR_SCHEME
-                       print_screen_output "Ok, exiting $SCRIPT_NAME now. You can set the colors later."
-                       exit 0
-               else
-                       print_screen_output "Error - Invalid Selection. You entered this: $user_selection"
-                       print_screen_output " "
-                       select_default_color_scheme
-               fi
-       else
-               print_screen_output "$LINE1"
-               print_lines_basic "0" "" "After finding the scheme number you like, simply run this again in a terminal to set the configuration data file for your irc client. You can set color schemes for the following: start inxi with -c plus:"
-               print_screen_output "94 (console, no X - $console); 95 (terminal, X - $virt_term); 96 (irc, gui, X - $irc_gui);"
-               print_screen_output "97 (irc, X, in terminal - $irc_x_term); 98 (irc, no X - $irc_console); 99 (global - $global)"
-               exit 0
-       fi
-
-       eval $LOGFE
+sub main {
+#      print Dumper \@ARGV;
+       eval $start if $b_log;
+       initialize();
+       ## use for start client debugging
+       # $debug = 3; # 3 prints timers
+       # set_debugger(); # for debugging of konvi issues
+       #my $ob_start = StartClient->new();
+       #$ob_start->get_client_data();
+       StartClient::get_client_data();
+       # print_line( Dumper \%client);
+       get_options();
+       set_debugger(); # right after so it's set
+       check_tools();
+       set_colors();
+       set_sep();
+       # print download_file('stdout','https://') . "\n";
+       generate_lines();
+       eval $end if $b_log;
+       cleanup();
+       # weechat's executor plugin forced me to do this, and rightfully so, 
+       # because else the exit code from the last command is taken..
+       exit 0;
 }
 
-########################################################################
-#### UTILITY FUNCTIONS
-########################################################################
-
 #### -------------------------------------------------------------------
-#### error handler, debugger, script updater
+#### INITIALIZE
 #### -------------------------------------------------------------------
 
-# Error handling
-# args: $1 - error number; $2 - optional, extra information; $3 - optional extra info
-error_handler()
-{
-       eval $LOGFS
-       local error_message=''
-
-       # assemble the error message
-       case $1 in
-               2)      error_message="large flood danger, debug buffer full!"
-                       ;;
-               3)      error_message="unsupported color scheme number: $2"
-                       ;;
-               4)      error_message="unsupported verbosity level: $2"
-                       ;;
-               5)      error_message="dependency not met: $2 not found in path.\nFor distribution installation package names and missing apps information, run: $SCRIPT_NAME --recommends"
-                       ;;
-               6)      error_message="/proc not found! Quitting..."
-                       ;;
-               7)      error_message="One of the options you entered in your script parameters: $2\nis not supported.The option may require extra arguments to work.\nFor supported options (and their arguments), check the help menu: $SCRIPT_NAME -h"
-                       ;;
-               8)      error_message="the self-updater failed, $DOWNLOADER exited with error: $2.\nYou probably need to be root.\nHint, to make for easy updates without being root, do: chown <user name> $SCRIPT_PATH/$SCRIPT_NAME"
-                       ;;
-               9)      error_message="unsupported debugging level: $2"
-                       ;;
-               10)
-                       error_message="the alt download url you provided: $2\nappears to be wrong, download aborted. Please note, the url\nneeds to end in /, without $SCRIPT_NAME, like: http://yoursite.com/downloads/"
-                       ;;
-               11)
-                       error_message="unsupported testing option argument: -! $2"
-                       ;;
-               12)
-                       error_message="the git branch download url: $2\nappears to be empty currently. Make sure there is an actual svn branch version\nactive before you try this again. Check https://github.com/smxi/inxi\nto verify the branch status."
-                       ;;
-               13)
-                       error_message="The -t option requires the following extra arguments (no spaces between letters/numbers):\nc m cm [required], for example: -t cm8 OR -t cm OR -t c9\n(numbers: 1-20, > 5 throttled to 5 in irc clients) You entered: $2"
-                       ;;
-               14)
-                       error_message="failed to write correctly downloaded $SCRIPT_NAME to location $SCRIPT_PATH.\nThis usually means you don't have permission to write to that location, maybe you need to be root?\nThe operation failed with error: $2"
-                       ;;
-               15)
-                       error_message="failed set execute permissions on $SCRIPT_NAME at location $SCRIPT_PATH.\nThis usually means you don't have permission to set permissions on files there, maybe you need to be root?\nThe operation failed with error: $2"
-                       ;;
-               16)
-                       error_message="$SCRIPT_NAME downloaded but the file data is corrupted. Purged data and using current version."
-                       ;;
-               17)
-                       error_message="All $SCRIPT_NAME self updater features have been disabled by the distribution\npackage maintainer. This includes the option you used: $2"
-                       ;;
-               18)
-                       error_message="The argument you provided for $2 does not have supported syntax.\nPlease use the following formatting:\n$3"
-                       ;;
-               19)
-                       error_message="The option $2 has been deprecated. Please use $3 instead.\nSee -h for instructions and syntax."
-                       ;;
-               20)
-                       error_message="The option you selected has been deprecated. $2\nSee the -h (help) menu for currently supported options."
-                       ;;
-               21)
-                       error_message="Width option requires an integer value of 80 or more.\nYou entered: $2"
-                       ;;
-               *)      error_message="error unknown: $@"
-                       set -- 99
-                       ;;
-       esac
-       # then print it and exit
-       print_screen_output "Error $1: $error_message"
-       eval $LOGFE
-       exit $1
-}
-
-# prior to script up set, pack the data into an array
-# then we'll print it out later.
-# args: $1 - $@ debugging string text
-script_debugger()
-{
-       eval $LOGFS
-       if [[ $B_SCRIPT_UP == 'true' ]];then
-               # only return if debugger is off and no pre start up errors have occured
-               if [[ $DEBUG -eq 0 && $DEBUG_BUFFER_INDEX -eq 0 ]];then
-                       return 0
-               # print out the stored debugging information if errors occured
-               elif [[ $DEBUG_BUFFER_INDEX -gt 0 ]];then
-                       for (( DEBUG_BUFFER_INDEX=0; DEBUG_BUFFER_INDEX < ${#A_DEBUG_BUFFER[@]}; DEBUG_BUFFER_INDEX++ ))
-                       do
-                               print_screen_output "${A_DEBUG_BUFFER[$DEBUG_BUFFER_INDEX]}"
-                       done
-                       DEBUG_BUFFER_INDEX=0
-               fi
-               # or print out normal debugger messages if debugger is on
-               if [[ $DEBUG -gt 0 ]];then
-                       print_screen_output "$1"
-               fi
-       else
-               if [[ $B_DEBUG_FLOOD == 'true' && $DEBUG_BUFFER_INDEX -gt 10 ]];then
-                       error_handler 2
-               # this case stores the data for later printout, will print out only
-               # at B_SCRIPT_UP == 'true' if array index > 0
-               else
-                       A_DEBUG_BUFFER[$DEBUG_BUFFER_INDEX]="$1"
-                       # increment count for next pre script up debugging error
-                       (( DEBUG_BUFFER_INDEX++ ))
-               fi
-       fi
-       eval $LOGFE
-}
-
-# NOTE: no logging available until get_parameters is run, since that's what sets logging
-# in order to trigger earlier logging manually set B_USE_LOGGING to true in top variables.
-# $1 alone: logs data; $2 with or without $3 logs func start/end.
-# $1 type (fs/fe/cat/raw) or logged data; [$2 is $FUNCNAME; [$3 - function args]]
-log_function_data()
-{
-       if [ "$B_USE_LOGGING" == 'true' ];then
-               local logged_data='' spacer='   ' line='----------------------------------------'
-               case $1 in
-                       fs)
-                               logged_data="Function: $2 - Primary: Start"
-                               if [ -n "$3" ];then
-                                       logged_data="$logged_data\n${spacer}Args: $3"
-                               fi
-                               spacer=''
-                               ;;
-                       fe)
-                               logged_data="Function: $2 - Primary: End"
-                               spacer=''
-                               ;;
-                       cat)
-                               if [[ $B_LOG_FULL_DATA == 'true' ]];then
-                                       for cat_file in $2
-                                       do
-                                               logged_data="$logged_data\n$line\nFull file data: cat $cat_file\n\n$( cat $cat_file )\n$line\n"
-                                       done
-                                       spacer=''
-                               fi
-                               ;;
-                       raw)
-                               if [[ $B_LOG_FULL_DATA == 'true' ]];then
-                                       logged_data="\n$line\nRaw system data:\n\n$2\n$line\n"
-                                       spacer=''
-                               fi
-                               ;;
-                       *)
-                               logged_data="$1"
-                               ;;
-               esac
-               # Create any required line breaks and strip out escape color code, either ansi (case 1)or irc (case 2).
-               # This pattern doesn't work for irc colors, if we need that someone can figure it out
-               if [[ -n $logged_data ]];then
-                       if [[ $B_LOG_COLORS != 'true' ]];then
-                               echo -e "${spacer}$logged_data" | sed $SED_RX 's/\x1b\[[0-9]{1,2}(;[0-9]{1,2}){0,2}m//g' >> $LOG_FILE
-                       else
-                               echo -e "${spacer}$logged_data" >> $LOG_FILE
-                       fi
-               fi
-       fi
-}
-
-# called in the initial -@ 10 script args setting so we can get logging as soon as possible
-# will have max 3 files, inxi.log, inxi.1.log, inxi.2.log
-create_rotate_logfiles()
-{
-       if [[ ! -d $SCRIPT_DATA_DIR ]];then
-               mkdir $SCRIPT_DATA_DIR
-       fi
-       # do the rotation if logfile exists
-       if [[ -f $LOG_FILE ]];then
-               # copy if present second to third
-               if [[ -f $LOG_FILE_1 ]];then
-                       mv -f $LOG_FILE_1 $LOG_FILE_2
-               fi
-               # then copy initial to second
-               mv -f $LOG_FILE $LOG_FILE_1
-       fi
-       # now create the logfile
-       touch $LOG_FILE
-       # and echo the start data
-       echo "=========================================================" >> $LOG_FILE
-       echo "START $SCRIPT_NAME LOGGING:"                               >> $LOG_FILE
-       echo "Script started: $( date +%Y-%m-%d-%H:%M:%S )"              >> $LOG_FILE
-       echo "=========================================================" >> $LOG_FILE
+sub initialize {
+       set_os();
+       set_path();
+       set_user_paths();
+       set_basics();
+       system_files('set');
+       get_configs();
+       # set_downloader();
+       set_display_width('live');
 }
 
-# args: $1 - download url, not including file name; $2 - string to print out
-# $3 - update type option
-# note that $1 must end in / to properly construct the url path
-script_self_updater()
-{
-       eval $LOGFS
-       local downloader_error=0 file_contents='' downloader_man_error=0 
-       local man_file_path="$MAN_FILE_LOCATION/inxi.1.gz"
-       
-       if [[ $B_IRC == 'true' ]];then
-               print_screen_output "Sorry, you can't run the $SCRIPT_NAME self updater option (-$3) in an IRC client."
-               exit 1
-       fi
-
-       print_screen_output "Starting $SCRIPT_NAME self updater."
-       print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER"
-       print_screen_output "Current version patch number: $SCRIPT_PATCH_NUMBER"
-       print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH using $2 as download source..."
-       case $DOWNLOADER in
-               curl)
-                       file_contents="$( curl -s $1$SCRIPT_NAME )" || downloader_error=$?
-                       ;;
-               fetch)
-                       file_contents="$( fetch -q -o - $1$SCRIPT_NAME )" || downloader_error=$?
-                       ;;
-               ftp)
-                       file_contents="$( ftp -o - $1$SCRIPT_NAME 2>/dev/null )" || downloader_error=$?
-                       ;;
-               wget)
-                       file_contents="$( wget -q -O - $1$SCRIPT_NAME )" || downloader_error=$?
-                       ;;
-               no-downloader)
-                       downloader_error=1
-                       ;;
-       esac
-
-       # then do the actual download
-       if [[  $downloader_error -eq 0 ]];then
-               # make sure the whole file got downloaded and is in the variable
-               if [[ -n $( grep '###\*\*EOF\*\*###' <<< "$file_contents" ) ]];then
-                       echo "$file_contents" > $SCRIPT_PATH/$SCRIPT_NAME || error_handler 14 "$?"
-                       chmod +x $SCRIPT_PATH/$SCRIPT_NAME || error_handler 15 "$?"
-                       SCRIPT_VERSION_NUMBER=$( parse_version_data 'main' )
-                       SCRIPT_PATCH_NUMBER=$( parse_version_data 'patch' )
-                       print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER"
-                       print_screen_output "New $2 version patch number: $SCRIPT_PATCH_NUMBER"
-                       print_screen_output "To run the new version, just start $SCRIPT_NAME again."
-                       print_screen_output "----------------------------------------"
-                       print_screen_output "Starting download of man page file now."
-                       if [[ ! -d $MAN_FILE_LOCATION ]];then
-                               print_screen_output "The required man directory was not detected on your system, unable to continue: $MAN_FILE_LOCATION"
-                       else
-                               if [[ $B_ROOT == 'true' ]];then
-                                       print_screen_output "Checking Man page download URL..."
-                                       if [[ -f /usr/share/man/man8/inxi.8.gz ]];then
-                                               print_screen_output "Updating man page location to man1."
-                                               mv -f /usr/share/man/man8/inxi.8.gz /usr/share/man/man1/inxi.1.gz 
-                                               if type -p mandb &>/dev/null;then
-                                                       exec $( type -p mandb ) -q 
-                                               fi
-                                       fi
-                                       if [[ $DOWNLOADER == 'wget' ]];then
-                                               wget -q --spider $MAN_FILE_DOWNLOAD || downloader_man_error=$?
-                                       fi
-                                       if [[ $downloader_man_error -eq 0 ]];then
-                                               if [[ $DOWNLOADER == 'wget' ]];then
-                                                       print_screen_output "Man file download URL verified: $MAN_FILE_DOWNLOAD"
-                                               fi
-                                               print_screen_output "Downloading Man page file now."
-                                               case $DOWNLOADER in
-                                                       curl)
-                                                               curl -s -o $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$?
-                                                               ;;
-                                                       fetch)
-                                                               fetch -q -o $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$?
-                                                               ;;
-                                                       ftp)
-                                                               ftp -o $man_file_path $MAN_FILE_DOWNLOAD 2>/dev/null || downloader_man_error=$?
-                                                               ;;
-                                                       wget)
-                                                               wget -q -O $man_file_path $MAN_FILE_DOWNLOAD || downloader_man_error=$?
-                                                               ;;
-                                                       no-downloader)
-                                                               downloader_man_error=1
-                                                               ;;
-                                               esac
-                                               if [[ $downloader_man_error -gt 0 ]];then
-                                                       print_screen_output "Oh no! Something went wrong downloading the Man gz file at: $MAN_FILE_DOWNLOAD"
-                                                       print_screen_output "Check the error messages for what happened. Error: $downloader_man_error"
-                                               else
-                                                       print_screen_output "Download/install of man page successful. Check to make sure it works: man inxi"
-                                               fi
-                                       else
-                                               print_screen_output "Man file download URL failed, unable to continue: $MAN_FILE_DOWNLOAD"
-                                       fi
-                               else
-                                       print_screen_output "Updating / Installing the Man page requires root user, writing to: $MAN_FILE_LOCATION"
-                                       print_screen_output "If you want the man page, you'll have to run $SCRIPT_NAME -$3 as root."
-                               fi
-                       fi
-                       exit 0
-               else
-                       error_handler 16
-               fi
-       # now run the error handlers on any wget failure
-       else
-               if [[ $2 == 'svn server' ]];then
-                       error_handler 8 "$downloader_error"
-               elif [[ $2 == 'alt server' ]];then
-                       error_handler 10 "$1"
-               else
-                       error_handler 12 "$1"
-               fi
-       fi
-       eval $LOGFS
-}
-
-# args: $1 - debug data type: sys|xorg|disk
-debug_data_collector()
-{
-       local xiin_app='' xiin_data_file='' xiin_download='' error='' b_run_xiin='false'
-       local debug_data_dir='' bsd_string='' xorg_d_files='' xorg_file='' a_distro_ids=''
-       local completed_gz_file='' xiin_file='xiin.py' ftp_upload='ftp.techpatterns.com/incoming'
-       local xiin_url="https://github.com/smxi/inxi/raw/xiin/$xiin_file"
-       local Line='-------------------------' root_string=''
-       local start_directory=$( pwd )
-       local host=$( tr '[A-Z]' '[a-z]' <<< "$HOSTNAME" )
-       local downloader_error=0 debug_i=''
-       
-       if [[ $B_DEBUG_I == 'true' ]];then
-               debug_i='i'
-       fi
-       
-       if [[ -n $host ]];then
-               host=${host// /-}
-       else
-               host="-no-host"
-       fi
-       if [[ -n $BSD_TYPE ]];then
-               bsd_string="-$BSD_TYPE-$BSD_VERSION"
-       fi
-       if [[ $( whoami ) == 'root' ]];then
-               root_string='-root'
-       fi
-       
-       debug_data_dir="inxi$bsd_string-$host-$(date +%Y%m%d-%H%M%S)-$1$root_string" 
-       
-       if [[ $B_IRC == 'false' ]];then
-               if [[ -n $ALTERNATE_FTP ]];then
-                       ftp_upload=$ALTERNATE_FTP
-               fi
-               echo "Starting debugging data collection type: $1"
-               echo -n "Checking/creating required directories... "
-               if [[ ! -d $SCRIPT_DATA_DIR ]];then
-                       mkdir $SCRIPT_DATA_DIR
-               fi
-               echo 'completed'
-               cd $SCRIPT_DATA_DIR
-               if [[ -d $SCRIPT_DATA_DIR/$debug_data_dir ]];then
-                       echo 'Deleting previous xiin data directory...'
-                       rm -rf $SCRIPT_DATA_DIR/$debug_data_dir
-               fi
-               mkdir $SCRIPT_DATA_DIR/$debug_data_dir
-               if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then
-                       echo 'Deleting previous tar.gz file...'
-                       rm -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz
-               fi
-               
-               echo 'Collecting system info: sensors, lsusb, lspci, lspci -v data, plus /proc data'
-               echo 'also checking for dmidecode data: note, you must be root to have dmidecode work.'
-               echo "Data going into: $SCRIPT_DATA_DIR/$debug_data_dir"
-               # bsd tools http://cb.vu/unixtoolbox.xhtml
-               # freebsd
-               if type -p pciconf &>/dev/null;then
-                       pciconf -l -cv &> $debug_data_dir/bsd-pciconf-cvl.txt
-                       pciconf -vl &> $debug_data_dir/bsd-pciconf-vl.txt
-                       pciconf -l &> $debug_data_dir/bsd-pciconf-l.txt
-               else
-                       touch $debug_data_dir/bsd-pciconf-absent
-               fi
-               # openbsd
-               if type -p pcidump &>/dev/null;then
-                       pcidump &> $debug_data_dir/bsd-pcidump-openbsd.txt
-                       pcidump -v &> $debug_data_dir/bsd-pcidump-v-openbsd.txt
-               else
-                       touch $debug_data_dir/bsd-pcidump-openbsd-absent
-               fi
-               # netbsd
-               if type -p pcictl &>/dev/null;then
-                       pcictl list &> $debug_data_dir/bsd-pcictl-list-netbsd.txt
-                       pcictl list -n &> $debug_data_dir/bsd-pcictl-list-n-netbsd.txt
-               else
-                       touch $debug_data_dir/bsd-pcictl-netbsd-absent
-               fi
-               if type -p sysctl &>/dev/null;then
-                       sysctl -a &> $debug_data_dir/bsd-sysctl-a.txt
-               else
-                       touch $debug_data_dir/bsd-sysctl-absent
-               fi
-               if type -p usbdevs &>/dev/null;then
-                       usbdevs -v  &> $debug_data_dir/bsd-usbdevs-v.txt
-               else
-                       touch $debug_data_dir/bsd-usbdevs-absent
-               fi
-               if type -p kldstat &>/dev/null;then
-                       kldstat  &> $debug_data_dir/bsd-kldstat.txt
-               else
-                       touch $debug_data_dir/bsd-kldstat-absent
-               fi
-               # diskinfo -v <disk>
-               # fdisk <disk>
-               dmidecode &> $debug_data_dir/dmidecode.txt
-               
-               get_repo_data "$SCRIPT_DATA_DIR/$debug_data_dir"
-               
-               if type -p shopt &>/dev/null;then
-                       shopt -s nullglob
-                       a_distro_ids=(/etc/*[-_]{release,version})
-                       shopt -u nullglob
-                       echo ${a_distro_ids[@]} &> $debug_data_dir/etc-distro-files.txt
-                       for distro_file in ${a_distro_ids[@]} /etc/issue
-                       do
-                               if [[ -f $distro_file ]];then
-                                       cat $distro_file &> $debug_data_dir/distro-file${distro_file//\//-}
-                               fi
-                       done
-               fi
-               dmesg &> $debug_data_dir/dmesg.txt
-               lscpu &> $debug_data_dir/lscpu.txt
-               lspci &> $debug_data_dir/lspci.txt
-               lspci -k &> $debug_data_dir/lspci-k.txt
-               lspci -knn &> $debug_data_dir/lspci-knn.txt
-               lspci -n &> $debug_data_dir/lspci-n.txt
-               lspci -nn &> $debug_data_dir/lspci-nn.txt
-               lspci -mm &> $debug_data_dir/lspci-mm.txt
-               lspci -mmnn &> $debug_data_dir/lspci-mmnn.txt
-               lspci -mmnnv &> $debug_data_dir/lspci-mmnnv.txt
-               lspci -v &> $debug_data_dir/lspci-v.txt
-               lsusb &> $debug_data_dir/lsusb.txt
-               if type -p hciconfig &>/dev/null;then
-                       hciconfig -a &> $debug_data_dir/hciconfig-a.txt
-               else
-                       touch $debug_data_dir/hciconfig-absent
-               fi
-               ls /sys &> $debug_data_dir/ls-sys.txt
-               ps aux &> $debug_data_dir/ps-aux.txt
-               ps -e &> $debug_data_dir/ps-e.txt
-               ps -p 1 &> $debug_data_dir/ps-p-1.txt
-               cat /proc/1/comm &> $debug_data_dir/proc-1-comm.txt
-               runlevel &> $debug_data_dir/runlevel.txt
-               if type -p rc-status &>/dev/null;then
-                       rc-status -a &> $debug_data_dir/rc-status-a.txt
-                       rc-status -l &> $debug_data_dir/rc-status-l.txt
-                       rc-status -r &> $debug_data_dir/rc-status-r.txt
-               else
-                       touch $debug_data_dir/rc-status-absent
-               fi
-               if type -p systemctl &>/dev/null;then
-                       systemctl list-units &> $debug_data_dir/systemctl-list-units.txt
-                       systemctl list-units --type=target &> $debug_data_dir/systemctl-list-units-target.txt
-               else
-                       touch $debug_data_dir/systemctl-absent
-               fi
-               if type -p initctl &>/dev/null;then
-                       initctl list &> $debug_data_dir/initctl-list.txt
-               else
-                       touch $debug_data_dir/initctl-absent
-               fi
-               sensors &> $debug_data_dir/sensors.txt
-               if type -p strings &>/dev/null;then
-                       touch $debug_data_dir/strings-present
-               else
-                       touch $debug_data_dir/strings-absent
-               fi
-               local id_dir='/sys/class/power_supply/' 
-               local ids=$( ls $id_dir 2>/dev/null )
-               if [[ -n $ids ]];then
-                       for batid in $ids 
-                       do
-                               cat $id_dir$batid'/uevent' &> $debug_data_dir/sys-power-supply-$batid.txt
-                       done
-               else
-                       touch $debug_data_dir/sys-power-supply-none
-               fi
-               
-               # leaving this commented out to remind that some systems do not
-               # support strings --version, but will just simply hang at that command
-               # which you can duplicate by simply typing: strings then hitting enter, you will get hang.
-               # strings --version  &> $debug_data_dir/strings.txt
-               if type -p nvidia-smi &>/dev/null;then
-                       nvidia-smi -q &> $debug_data_dir/nvidia-smi-q.txt
-                       nvidia-smi -q -x &> $debug_data_dir/nvidia-smi-xq.txt
-               else
-                       touch $debug_data_dir/nvidia-smi-absent
-               fi
-               head -n 1 /proc/asound/card*/codec* &> $debug_data_dir/proc-asound-card-codec.txt
-               if [[ -f /proc/version ]];then
-                       cat /proc/version &> $debug_data_dir/proc-version.txt
-               else
-                       touch $debug_data_dir/proc-version-absent
-               fi
-               echo $CC &> $debug_data_dir/cc-content.txt
-               ls /usr/bin/gcc* &> $debug_data_dir/gcc-sys-versions.txt
-               if type -p gcc &>/dev/null;then
-                       gcc --version &> $debug_data_dir/gcc-version.txt
-               else
-                       touch $debug_data_dir/gcc-absent
-               fi
-               if type -p clang &>/dev/null;then
-                       clang --version &> $debug_data_dir/clang-version.txt
-               else
-                       touch $debug_data_dir/clang-absent
-               fi
-               cat /etc/src.conf &> $debug_data_dir/bsd-etc-src-conf.txt
-               cat /etc/make.conf &> $debug_data_dir/bsd-etc-make-conf.txt
-               cat /etc/issue &> $debug_data_dir/etc-issue.txt
-               cat $FILE_LSB_RELEASE &> $debug_data_dir/lsb-release.txt
-               cat $FILE_OS_RELEASE &> $debug_data_dir/os-release.txt
-               cat $FILE_ASOUND_DEVICE &> $debug_data_dir/proc-asound-device.txt
-               cat $FILE_ASOUND_VERSION &> $debug_data_dir/proc-asound-version.txt
-               cat $FILE_CPUINFO &> $debug_data_dir/proc-cpu-info.txt
-               cat $FILE_MEMINFO &> $debug_data_dir/proc-meminfo.txt
-               cat $FILE_MODULES &> $debug_data_dir/proc-modules.txt
-               cat /proc/net/arp &> $debug_data_dir/proc-net-arp.txt 
-               # bsd data
-               cat /var/run/dmesg.boot &> $debug_data_dir/bsd-var-run-dmesg.boot.txt 
-               echo $COLS_INNER &> $debug_data_dir/cols-inner.txt
-               
-               check_recommends_user_output &> $debug_data_dir/check-recommends-user-output.txt
-               # first download and verify xiin
-               if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then
-                       touch $SCRIPT_DATA_DIR/$debug_data_dir/xiin-error.txt
-                       echo "Downloading required tree traverse tool $xiin_file..."
-                       if [[ -f xiin && ! -f $xiin_file ]];then
-                               mv -f xiin $xiin_file
-                       fi
-                       # -Nc is creating really weird download anomolies, so using -O instead
-                       case $DOWNLOADER in
-                               curl)
-                                       xiin_download="$( curl -s $xiin_url )" || downloader_error=$?
-                                       ;;
-                               fetch)
-                                       xiin_download="$( fetch -q -o - $xiin_url )" || downloader_error=$?
-                                       ;;
-                               ftp)
-                                       xiin_download="$( ftp -o - $xiin_url 2>/dev/null )" || downloader_error=$?
-                                       ;;
-                               wget)
-                                       xiin_download="$( wget -q -O - $xiin_url )" || downloader_error=$?
-                                       ;;
-                               no-downloader)
-                                       downloader_error=1
-                                       ;;
-                       esac
-                       # if nothing got downloaded kick out error, otherwise we'll use an older version
-                       if [[ $downloader_error -gt 0 && ! -f $xiin_file ]];then
-                               echo -e "ERROR: Failed to download required file: $xiin_file\nMaybe the remote site is down or your networking is broken?"
-                               echo "Continuing with incomplete data collection."
-                               echo "$xiin_file download failed and no existing $xiin_file" >> $debug_data_dir/xiin-error.txt
-                       elif [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) || -f $xiin_file ]];then
-                               if [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) ]];then
-                                       echo "Updating $xiin_file from remote location"
-                                       echo "$xiin_download" > $xiin_file
-                               else
-                                       echo "Using local $xiin_file due to download failure"
-                               fi
-                               b_run_xiin='true'
-                       else
-                               echo -e "ERROR: $xiin_file downloaded but the program file data is corrupted.\nContinuing with incomplete data collection."
-                               echo "$xiin_file downloaded but the program file data is corrupted." >> $debug_data_dir/xiin-error.txt
-                       fi
-               fi
-               # note, only bash 4> supports ;;& for case, so using if/then here
-               if [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then
-                       xiin_data_file=$SCRIPT_DATA_DIR/$debug_data_dir/xiin-sys.txt
-                       echo 'Collecting networking data...'
-                       ifconfig &> $debug_data_dir/ifconfig.txt
-                       ip addr &> $debug_data_dir/ip-addr.txt
-                       if [[ $b_run_xiin == 'true' && -z $BSD_TYPE ]];then
-                               echo $Line
-                               echo "Running $xiin_file tool now on /sys..."
-                               echo "Using Python version:" && python --version
-                               python --version &> $debug_data_dir/python-version.txt
-                               python ./$xiin_file -d /sys -f $xiin_data_file
-                               if [[ $? -ne 0 ]];then
-                                       error=$?
-                                       echo -e "ERROR: $xiin_file exited with error $error - removing data file.\nContinuing with incomplete data collection."
-                                       echo "Continuing with incomplete data collection."
-                                       rm -f $xiin_data_file
-                                       echo "$xiin_file data generation failed with python error $error" >> $debug_data_dir/xiin-error.txt
-                               fi
-                               echo $Line
-                       fi
-               fi
-               if [[ $1 == 'xorg' || $1 == 'all' ]];then
-                       if [[ $B_RUNNING_IN_DISPLAY != 'true' ]];then
-                               echo 'Warning: only some of the data collection can occur if you are not in X'
-                               touch $debug_data_dir/warning-user-not-in-x
-                       fi
-                       if [[ $B_ROOT == 'true' ]];then
-                               echo 'Warning: only some of the data collection can occur if you are running as Root user'
-                               touch $debug_data_dir/warning-root-user
-                       fi
-                       echo 'Collecting Xorg log and xorg.conf files'
-                       if [[ -e $FILE_XORG_LOG ]];then
-                               cat $FILE_XORG_LOG &> $debug_data_dir/xorg-log-file.txt
-                       else
-                               touch $debug_data_dir/xorg-log-file-absent
-                       fi
-                       if [[ -e /etc/X11/xorg.conf ]];then
-                               cat /etc/X11/xorg.conf &> $debug_data_dir/xorg-conf.txt
-                       else
-                               touch $debug_data_dir/xorg-conf-file-absent
-                       fi
-                       if [[ -n $( ls /etc/X11/xorg.conf.d/ 2>/dev/null ) ]];then
-                               ls /etc/X11/xorg.conf.d &> $debug_data_dir/ls-etc-x11-xorg-conf-d.txt
-                               xorg_d_files=$(ls /etc/X11/xorg.conf.d)
-                               for xorg_file in $xorg_d_files
-                               do
-                                       cat /etc/X11/xorg.conf.d/$xorg_file &> $debug_data_dir/xorg-conf-d-$xorg_file.txt
-                               done
-                       else
-                               touch $debug_data_dir/xorg-conf-d-files-absent
-                       fi
-                       echo 'Collecting X, xprop, glxinfo, xrandr, xdpyinfo data, wayland, weston...'
-                       if type -p weston-info &>/dev/null; then
-                               weston-info &> $debug_data_dir/weston-info.txt
-                       else
-                               touch $debug_data_dir/weston-info-absent
-                       fi
-                       if type -p weston &>/dev/null; then
-                               weston --version &> $debug_data_dir/weston-version.txt
-                       else
-                               touch $debug_data_dir/weston-absent
-                       fi
-                       if type -p xprop &>/dev/null; then
-                               xprop -root &> $debug_data_dir/xprop_root.txt
-                       else
-                               touch $debug_data_dir/xprop-absent
-                       fi
-                       if type -p xprop &>/dev/null; then
-                               glxinfo &> $debug_data_dir/glxinfo.txt
-                       else
-                               touch $debug_data_dir/glxinfo-absent
-                       fi
-                       if type -p xdpyinfo &>/dev/null; then
-                               xdpyinfo &> $debug_data_dir/xdpyinfo.txt
-                       else
-                               touch $debug_data_dir/xdpyinfo-absent
-                       fi
-                       if type -p xrandr &>/dev/null; then
-                               xrandr &> $debug_data_dir/xrandr.txt
-                       else
-                               touch $debug_data_dir/xrandr-absent
-                       fi
-                       if type -p X &>/dev/null; then
-                               X -version &> $debug_data_dir/x-version.txt
-                       else
-                               touch $debug_data_dir/x-absent
-                       fi
-                       if type -p Xorg &>/dev/null; then
-                               Xorg -version &> $debug_data_dir/xorg-version.txt
-                       else
-                               touch $debug_data_dir/xorg-absent
-                       fi
-                       
-                       echo $GNOME_DESKTOP_SESSION_ID &> $debug_data_dir/gnome-desktop-session-id.txt
-                       # kde 3 id
-                       echo $KDE_FULL_SESSION &> $debug_data_dir/kde3-full-session.txt
-                       echo $KDE_SESSION_VERSION &> $debug_data_dir/kde-gte-4-session-version.txt
-                       if type -p kf5-config &>/dev/null; then
-                               kf5-config --version &> $debug_data_dir/kde-kf5-config-version-data.txt
-                       elif type -p kf6-config &>/dev/null; then
-                               kf6-config --version &> $debug_data_dir/kde-kf6-config-version-data.txt
-                       elif type -p kf$KDE_SESSION_VERSION-config &>/dev/null; then
-                               kf$KDE_SESSION_VERSION-config --version &> $debug_data_dir/kde-kf$KDE_SESSION_VERSION-KSV-config-version-data.txt
-                       else
-                               touch $debug_data_dir/kde-kf-config-absent
-                       fi
-                       if type -p plasmashell &>/dev/null; then
-                               plasmashell --version &> $debug_data_dir/kde-plasmashell-version-data.txt
-                       else
-                               touch $debug_data_dir/kde-plasmashell-absent
-                       fi
-                       if type -p kwin_x11 &>/dev/null; then
-                               kwin_x11 --version &> $debug_data_dir/kde-kwin_x11-version-data.txt
-                       else
-                               touch $debug_data_dir/kde-kwin_x11-absent
-                       fi
-                       if type -p kded4 &>/dev/null; then
-                               kded4 --version &> $debug_data_dir/kded4-version-data.txt
-                       elif type -p kded5 &>/dev/null; then
-                               kded5 --version &> $debug_data_dir/kded5-version-data.txt
-                       elif type -p kded &>/dev/null; then
-                               kded --version &> $debug_data_dir/kded-version-data.txt
-                       else
-                               touch $debug_data_dir/kded-$KDE_SESSION_VERSION-absent
-                       fi
-                       # kde 5/plasma desktop 5, this is maybe an extra package and won't be used
-                       if type -p about-distro &>/dev/null; then
-                               about-distro &> $debug_data_dir/kde-about-distro.txt
-                       else
-                               touch $debug_data_dir/kde-about-distro-absent
-                       fi
-                       echo $XDG_CURRENT_DESKTOP &> $debug_data_dir/xdg-current-desktop.txt
-               fi
-               if [[ $1 == 'disk' || $1 == 'all' ]];then
-                       echo 'Collecting dev, label, disk, uuid data, df...'
-                       ls -l /dev &> $debug_data_dir/dev-data.txt
-                       ls -l /dev/disk &> $debug_data_dir/dev-disk-data.txt
-                       ls -l /dev/disk/by-id &> $debug_data_dir/dev-disk-id-data.txt
-                       ls -l /dev/disk/by-label &> $debug_data_dir/dev-disk-label-data.txt
-                       ls -l /dev/disk/by-uuid &> $debug_data_dir/dev-disk-uuid-data.txt
-                       # http://comments.gmane.org/gmane.linux.file-systems.zfs.user/2032
-                       ls -l /dev/disk/by-wwn &> $debug_data_dir/dev-disk-wwn-data.txt
-                       ls -l /dev/disk/by-path &> $debug_data_dir/dev-disk-path-data.txt
-                       ls -l /dev/mapper &> $debug_data_dir/dev-disk-mapper-data.txt
-                       readlink /dev/root &> $debug_data_dir/dev-root.txt
-                       df -h -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-h-T-P-excludes.txt
-                       df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-T-P-excludes.txt
-                       df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs --total &> $debug_data_dir/df-T-P-excludes-total.txt
-                       df -h -T &> $debug_data_dir/bsd-df-h-T-no-excludes.txt
-                       df -h &> $debug_data_dir/bsd-df-h-no-excludes.txt
-                       df -k -T &> $debug_data_dir/bsd-df-k-T-no-excludes.txt
-                       df -k &> $debug_data_dir/bsd-df-k-no-excludes.txt
-                       atacontrol list &> $debug_data_dir/bsd-atacontrol-list.txt
-                       camcontrol devlist &> $debug_data_dir/bsd-camcontrol-devlist.txt
-                       # bsd tool
-                       mount &> $debug_data_dir/mount.txt
-                       btrfs filesystem show  &> $debug_data_dir/btrfs-filesystem-show.txt
-                       btrfs filesystem show --mounted  &> $debug_data_dir/btrfs-filesystem-show-mounted.txt
-                       # btrfs filesystem show --all-devices  &> $debug_data_dir/btrfs-filesystem-show-all-devices.txt
-                       gpart list &> $debug_data_dir/bsd-gpart-list.txt
-                       gpart show &> $debug_data_dir/bsd-gpart-show.txt
-                       gpart status &> $debug_data_dir/bsd-gpart-status.txt
-                       swapctl -l -k &> $debug_data_dir/bsd-swapctl-l-k.txt
-                       swapon -s &> $debug_data_dir/swapon-s.txt
-                       sysctl -b kern.geom.conftxt &> $debug_data_dir/bsd-sysctl-b-kern.geom.conftxt.txt
-                       sysctl -b kern.geom.confxml &> $debug_data_dir/bsd-sysctl-b-kern.geom.confxml.txt
-                       zfs list &> $debug_data_dir/bsd-zfs-list.txt
-                       zpool list &> $debug_data_dir/bsd-zpool-list.txt
-                       zpool list -v &> $debug_data_dir/bsd-zpool-list-v.txt
-                       df -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 &> $debug_data_dir/df-P-excludes.txt
-                       df -P &> $debug_data_dir/bsd-df-P-no-excludes.txt
-                       cat /proc/mdstat &> $debug_data_dir/proc-mdstat.txt
-                       cat $FILE_PARTITIONS &> $debug_data_dir/proc-partitions.txt
-                       cat $FILE_SCSI &> $debug_data_dir/proc-scsi.txt
-                       cat $FILE_MOUNTS &> $debug_data_dir/proc-mounts.txt
-                       cat /proc/sys/dev/cdrom/info &> $debug_data_dir/proc-cdrom-info.txt
-                       ls /proc/ide/ &> $debug_data_dir/proc-ide.txt
-                       cat /proc/ide/*/* &> $debug_data_dir/proc-ide-hdx-cat.txt
-                       cat /etc/fstab &> $debug_data_dir/etc-fstab.txt
-                       cat /etc/mtab &> $debug_data_dir/etc-mtab.txt
-               fi
-               echo 'Creating inxi output file now. This can take a few seconds...'
-               echo "Starting $SCRIPT_NAME from: $start_directory"
-               cd $start_directory
-               $SCRIPT_PATH/$SCRIPT_NAME -F${debug_i}Rfrploudmxxx -c 0 -@ 8 -y 120 > $SCRIPT_DATA_DIR/$debug_data_dir/inxi-F${debug_i}Rfrploudmxxxy120.txt
-               cp $LOG_FILE $SCRIPT_DATA_DIR/$debug_data_dir
-               if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then
-                       echo "Found and removing previous tar.gz data file: $debug_data_dir.tar.gz"
-                       rm -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz
-               fi
-               cd $SCRIPT_DATA_DIR
-               echo 'Creating tar.gz compressed file of this material now. Contents:'
-               echo $Line
-               tar -cvzf $debug_data_dir.tar.gz $debug_data_dir
-               echo $Line
-               echo 'Cleaning up leftovers...'
-               rm -rf $debug_data_dir
-               echo 'Testing gzip file integrity...'
-               gzip -t $debug_data_dir.tar.gz
-               if [[ $? -gt 0 ]];then
-                       echo 'Data in gz is corrupted, removing gzip file, try running data collector again.'
-                       rm -f $debug_data_dir.tar.gz
-                       echo "Data in gz is corrupted, removed gzip file" >> $debug_data_dir/gzip-error.txt
-               else
-                       echo 'All done, you can find your data gzipped directory here:'
-                       completed_gz_file=$SCRIPT_DATA_DIR/$debug_data_dir.tar.gz
-                       echo $completed_gz_file
-                       if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then
-                               echo $Line
-                               if [[ $b_run_xiin == 'true' ]];then
-                                       echo "Running automatic upload of data to remote server $ftp_upload now..."
-                                       python ./$xiin_file --version
-                                       python ./$xiin_file -u $completed_gz_file $ftp_upload
-                                       if [[ $? -gt 0 ]];then
-                                               echo $Line
-                                               echo "Error: looks like the ftp upload failed. Error number: $?"
-                                               echo "The ftp upload failed. Error number: $?" >> $debug_data_dir/xiin-error.txt
-                                       fi
-                               else
-                                       echo 'Unable to run the automoatic ftp upload because of an error with the xiin download.'
-                                       echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $debug_data_dir/xiin-error.txt
-                               fi
-                       else
-                               echo 'You can upload this here using most file managers: ftp.techpatterns.com/incoming'
-                               echo 'then let a maintainer know it is uploaded.'
-                       fi
-               fi
-       else
-               echo 'This feature only available in console or shell client! Exiting now.'
-       fi
-       exit 0
-}
-
-check_recommends_user_output()
-{
-       local Line=$LINE1
-       local gawk_version='N/A' sed_version='N/A' sudo_version='N/A' python_version='N/A'
-       local downloaders_bsd=''
-       
-       if [[ $B_IRC == 'true' ]];then
-               print_screen_output "Sorry, you can't run this option in an IRC client."
-               exit 1
-       fi
-       if [[ -n $BSD_TYPE ]];then
-               downloaders_bsd='
-               fetch:BSD-only~BSD-only~BSD-only~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(BSDs)
-               ftp:ftp-OpenBSD-only~ftp-OpenBSD-only~ftp-OpenBSD-only~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(OpenBSD_only)'
-       fi
-       initialize_paths
-       print_lines_basic "0" "" "$SCRIPT_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SCRIPT_NAME uses. Python is only for debugging data collection."
-       echo $Line
-       echo "Bash version: $( bash --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU bash/ {print $4}' )"
-       if type -p gawk &>/dev/null;then
-               gawk_version=$( gawk --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU Awk/ {print $3}' )
-       fi
-       if type -p sed &>/dev/null;then
-               sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU sed version/ {print $4}' )
-               if [[ -z $sed_version ]];then
-                       # note: bsd sed shows error with --version flag
-                       sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^sed: illegal option/ {print "BSD sed"}' )
-               fi
-       fi
-       if type -p sudo &>/dev/null;then
-               sudo_version=$( sudo -V 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Sudo version/ {print $3}' )
-       fi
-       if type -p python &>/dev/null;then
-               python_version=$( python --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Python/ {print $2}' )
-       fi
-       echo "Gawk version: $gawk_version"
-       echo "Sed version: $sed_version"
-       echo "Sudo version: $sudo_version"
-       echo "Python version: $python_version"
-       echo $Line
-       
-       echo "Test One: Required System Directories (Linux Only)."
-       print_lines_basic "0" "" "If one of these system directories is missing, $SCRIPT_NAME cannot operate:"
-       echo 
-       check_recommends_items 'required-dirs'
-       
-       echo "Test Two: Required Core Applications."
-       print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME cannot operate:"
-       echo 
-       check_recommends_items 'required-apps'
-       
-       print_lines_basic "0" "" "Test Three: Script Recommends for Graphics Features."
-       print_lines_basic "0" "" "NOTE: If you do not use X these do not matter (like a headless server). Otherwise, if one of these applications is missing, $SCRIPT_NAME will have incomplete output:"
-       echo 
-       check_recommends_items 'recommended-x-apps'
-       
-       echo 'Test Four: Script Recommends for Remaining Features.' 
-       print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME will have incomplete output:"
-       echo 
-       check_recommends_items 'recommended-apps'
-       
-       echo 'Test Five: Script Recommends for Remaining Features.' 
-       print_lines_basic "0" "" "One of these downloaders needed for options -i/-w/-W (-U/-! [11-15], if supported):"
-       echo 
-       check_recommends_items 'downloaders'
-       
-       echo 'Test Six: System Directories for Various Information.'
-       echo '(Unless otherwise noted, these are for GNU/Linux systems)' 
-       print_lines_basic "0" "" "If one of these directories is missing, $SCRIPT_NAME may have incomplete output:"
-       echo 
-       check_recommends_items 'system-dirs'
-       
-       echo 'Test Seven: System Files for Various Information.'
-       echo '(Unless otherwise noted, these are for GNU/Linux systems)' 
-       print_lines_basic "0" "" "If one of these files is missing, $SCRIPT_NAME may have incomplete output:"
-       echo 
-       check_recommends_items 'system-files'
-       
-       echo 'All tests completed.' 
+sub check_tools {
+       my ($action,$program,$message,@data,%commands,%hash);
+       if ( $b_dmi ){
+               $action = 'use';
+               if ($program = check_program('dmidecode')) {
+                       @data = grabber("$program -t chassis -t baseboard -t processor 2>&1");
+                       if (scalar @data < 15){
+                               if ($b_root) {
+                                       foreach (@data){
+                                               if ($_ =~ /No SMBIOS/i){
+                                                       $action = 'smbios';
+                                                       last;
+                                               }
+                                               elsif ($_ =~ /^\/dev\/mem: Operation/i){
+                                                       $action = 'no-data';
+                                                       last;
+                                               }
+                                               else {
+                                                       $action = 'unknown-error';
+                                                       last;
+                                               }
+                                       }
+                               }
+                               else {
+                                       if (grep { $_ =~ /^\/dev\/mem: Permission/i } @data){
+                                               $action = 'permissions';
+                                       }
+                                       else {
+                                               $action = 'unknown-error';
+                                       }
+                               }
+                       }
+               }
+               else {
+                       $action = 'missing';
+               }
+               %hash = (
+               'dmidecode' => {
+               'action' => $action,
+               'missing' => 'Required program dmidecode not available',
+               'permissions' => 'Unable to run dmidecode. Are you root?',
+               'smbios' => 'No SMBIOS data for dmidecode to process',
+               'no-data' => 'dmidecode is not allowed to read /dev/mem',
+               'unknown-error' => 'dmidecode was unable to generate data',
+               },
+               );
+               %alerts = (%alerts, %hash);
+       }
+       # note: gnu/linux has sysctl so it may be used that for something if present
+       # there is lspci for bsds so doesn't hurt to check it
+       if ($b_pci || $b_sysctl){
+               if (!$bsd_type){
+                       if ($b_pci ){
+                               %hash = ('lspci' => '-n',);
+                               %commands = (%commands,%hash);
+                       }
+               }
+               else {
+                       if ($b_pci ){
+                               %hash = ('pciconf' => '-l',);
+                               %commands = (%commands,%hash);
+                       }
+                       if ($b_sysctl ){
+                               # note: there is a case of kernel.osrelease but it's a linux distro
+                               %hash = ('sysctl' => 'kern.osrelease',);
+                               %commands = (%commands,%hash);
+                       }
+               }
+               foreach ( keys %commands ){
+                       $action = 'use';
+                       if ($program = check_program($_)) {
+                               # > 0 means error in shell
+                               #my $cmd = "$program $commands{$_} >/dev/null";
+                               #print "$cmd\n";
+                               $action = 'permissions' if system("$program $commands{$_} >/dev/null 2>&1");
+                       }
+                       else {
+                               $action = 'missing';
+                       }
+                       %hash = (
+                       $_ => {
+                       'action' => $action,
+                       'missing' => "Missing system tool: $_. Output will be incomplete",
+                       'permissions' => "Unable to run $_. Root required?",
+                       },
+                       );
+                       %alerts = (%alerts, %hash);
+               }
+       }
+       %commands = ();
+       if ( $show{'sensor'} ){
+               %commands = ('sensors' => 'linux',);
+       }
+       # note: lsusb ships in FreeBSD ports sysutils/usbutils
+       if ( $usb_level ){
+               %hash = ('lsusb' => 'all',);
+               %commands = (%commands,%hash);
+               %hash = ('usbdevs' => 'bsd',);
+               %commands = (%commands,%hash);
+       }
+       if ($show{'ip'} || ($bsd_type && $show{'network-advanced'})){
+               %hash = (
+               'ip' => 'linux',
+               'ifconfig' => 'all',
+               );
+               %commands = (%commands,%hash);
+       }
+       foreach ( keys %commands ){
+               $action = 'use';
+               $message = 'Present and working';
+               if ( ($commands{$_} eq 'linux' && $os ne 'linux' ) || ($commands{$_} eq 'bsd' && $os eq 'linux' ) ){
+                       $message = "No " . ucfirst($os) . " support. Is a comparable $_ tool available?";
+                       $action = 'platform';
+               }
+               elsif (!check_program($_)){
+                       $message = "Required tool $_ not installed. Check --recommends";
+                       $action = 'missing';
+               }
+               %hash = (
+               $_ => {
+               'action' => $action,
+               'missing' => $message,
+               'platform' => $message,
+               },
+               );
+               %alerts = (%alerts, %hash);
+       }
+       # print Dumper \%alerts;
+       # only use sudo if not root, -n option requires sudo -V 1.7 or greater. 
+       # for some reason sudo -n with < 1.7 in Perl does not print to stderr
+       # sudo will just error out which is the safest course here for now,
+       # otherwise that interactive sudo password thing is too annoying
+       # important: -n makes it non interactive, no prompt for password
+       if (!$b_root && $b_sudo && (my $path = main::check_program('sudo') )) {
+               my @data = program_values('sudo');
+               my $version = program_version($path,$data[0],$data[1],$data[2],$data[5]);
+               $version =~ s/^([0-9]+\.[0-9]+).*/$1/;
+               $sudo = "$path -n " if $version >= 1.7;
+       }
+       set_fake_tools() if $b_fake_bsd;
 }
-# args: $1 - check item
-check_recommends_items()
-{
-       local item='' item_list='' item_string='' missing_items='' missing_string=''
-       local package='' application='' feature='' type='' starter='' finisher=''
-       local package_deb='' package_pacman='' package_rpm='' 
-       local print_string='' separator='' width=56
-       local required_dirs='/proc /sys'
-       # package-owner: 1 - debian/ubuntu; 2 - arch; 3 - yum/rpm
-       # pardus: pisi sf -q /usr/bin/package
-       local required_apps='
-       df:coreutils~coreutils~coreutils~:partition_data 
-       gawk:gawk~gawk~gawk~:core_tool
-       grep:grep~grep~grep~:string_search 
-       lspci:pciutils~pciutils~pciutils~:hardware_data 
-       ps:procps~procps~procps~:process_data 
-       readlink:coreutils~coreutils~coreutils~: 
-       sed:sed~sed~sed~:string_replace 
-       tr:coreutils~coreutils~coreutils~:character_replace 
-       uname:uname~coreutils~coreutils~:kernel_data 
-       wc:coreutils~coreutils~coreutils~:word_character_count
-       '
-       local x_recommends='
-       glxinfo:mesa-utils~mesa-demos~glx-utils_(openSUSE_12.3_and_later_Mesa-demo-x)~:-G_glx_info 
-       xdpyinfo:X11-utils~xorg-xdpyinfo~xorg-x11-utils~:-G_multi_screen_resolution 
-       xprop:X11-utils~xorg-xprop~x11-utils~:-S_desktop_data 
-       xrandr:x11-xserver-utils~xrandr~x11-server-utils~:-G_single_screen_resolution
-       '
-       local recommended_apps='
-       dig:dnsutils~dnsutils~bind-utils:-i_first_wlan_ip_default_test
-       dmidecode:dmidecode~dmidecode~dmidecode~:-M_if_no_sys_machine_data;_-m_memory 
-       file:file~file~file~:-o_unmounted_file_system
-       hciconfig:bluez~bluez-utils~bluez-utils~:-n_-i_bluetooth_data
-       hddtemp:hddtemp~hddtemp~hddtemp~:-Dx_show_hdd_temp 
-       ifconfig:net-tools~net-tools~net-tools~:-i_ip_lan-deprecated
-       ip:iproute~iproute2~iproute~:-i_ip_lan
-       sensors:lm-sensors~lm_sensors~lm-sensors~:-s_sensors_output
-       strings:binutils~~~:-I_sysvinit_version
-       lsusb:usbutils~usbutils~usbutils~:-A_usb_audio;-N_usb_networking 
-       modinfo:module-init-tools~module-init-tools~module-init-tools~:-Ax,-Nx_module_version 
-       runlevel:sysvinit~sysvinit~systemd~:-I_runlevel
-       sudo:sudo~sudo~sudo~:-Dx_hddtemp-user;-o_file-user
-       uptime:procps~procps~procps~:-I_uptime_(check_which_package_owns_Debian)
-       '
-       
-       local downloaders="
-       wget:wget~wget~wget~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(if_supported)
-       curl:curl~curl~curl~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(if_supported)
-       $downloaders_bsd
-       "
-       local recommended_dirs='
-       /sys/class/dmi/id:-M_system,_motherboard,_bios
-       /dev:-l,-u,-o,-p,-P,-D_disk_partition_data
-       /dev/disk/by-label:-l,-o,-p,-P_partition_labels
-       /dev/disk/by-uuid:-u,-o,-p,-P_partition_uuid
-       '
-       local recommended_files="
-       $FILE_ASOUND_DEVICE:-A_sound_card_data
-       $FILE_ASOUND_VERSION:-A_ALSA_data
-       $FILE_CPUINFO:-C_cpu_data
-       $FILE_LSB_RELEASE:-S_distro_version_data_[deprecated]
-       $FILE_MDSTAT:-R_mdraid_data
-       $FILE_MEMINFO:-I_memory_data
-       $FILE_OS_RELEASE:-S_distro_version_data
-       $FILE_PARTITIONS:-p,-P_partitions_data
-       $FILE_MODULES:-G_module_data
-       $FILE_MOUNTS:-P,-p_partition_advanced_data
-       $FILE_DMESG_BOOT:-D,-d_disk_data_[BSD_only]
-       $FILE_SCSI:-D_Advanced_hard_disk_data_[used_rarely]
-       $FILE_XORG_LOG:-G_graphics_driver_load_status
-       "
-       
-       if [[ -n $COLS_INNER ]];then
-               if [[ $COLS_INNER -ge 90 ]];then
-                       width=${#LINE1} # match width of $LINE1
-               elif [[ $COLS_INNER -ge 78 ]];then
-                       width=$(( $COLS_INNER - 11 ))
-               fi
-       fi
-       
-       case $1 in
-               downloaders)
-                       item_list=$downloaders
-                       item_string='Downloaders'
-                       item_string=''
-                       missing_string='downloaders, and their corresponding packages,'
-                       type='applications'
-                       ;;
-               required-dirs)
-                       item_list=$required_dirs
-                       item_string='Required file system'
-                       item_string=''
-                       missing_string='system directories'
-                       type='directories'
-                       ;;
-               required-apps)
-                       item_list=$required_apps
-                       item_string='Required application'
-                       item_string=''
-                       missing_string='applications, and their corresponding packages,'
-                       type='applications'
-                       ;;
-               recommended-x-apps)
-                       item_list=$x_recommends
-                       item_string='Recommended X application'
-                       item_string=''
-                       missing_string='applications, and their corresponding packages,'
-                       type='applications'
-                       ;;
-               recommended-apps)
-                       item_list=$recommended_apps
-                       item_string='Recommended application'
-                       item_string=''
-                       missing_string='applications, and their corresponding packages,'
-                       type='applications'
-                       ;;
-               system-dirs)
-                       item_list=$recommended_dirs
-                       item_string='System directory'
-                       item_string=''
-                       missing_string='system directories'
-                       type='directories'
-                       ;;
-               system-files)
-                       item_list=$recommended_files
-                       item_string='System file'
-                       item_string=''
-                       missing_string='system files'
-                       type='files'
-                       ;;
-       esac
-       # great trick from: http://ideatrash.net/2011/01/bash-string-padding-with-sed.html
-       # left pad: sed -e :a -e 's/^.\{1,80\}$/& /;ta'
-       # right pad: sed -e :a -e 's/^.\{1,80\}$/ &/;ta'
-       # center pad: sed -e :a -e 's/^.\{1,80\}$/ & /;ta'
-       
-       for item in $item_list
-       do
-               if [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 0 ]];then
-                       application=$item
-                       package=''
-                       feature=''
-                       location=''
-               elif [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 1 ]];then
-                       application=$( cut -d ':' -f 1 <<< $item )
-                       package=''
-                       feature=$( cut -d ':' -f 2 <<< $item )
-                       location=''
-               else
-                       application=$( cut -d ':' -f 1 <<< $item )
-                       package=$( cut -d ':' -f 2 <<< $item )
-                       location=$( type -p $application )
-                       if [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 2 ]];then
-                               feature=$( cut -d ':' -f 3 <<< $item )
-                       else
-                               feature=''
-                       fi
-               fi
-               if [[ -n $feature ]];then
-                       print_string="$item_string$application (info: $( sed 's/_/ /g' <<< $feature ))"
-               else
-                       print_string="$item_string$application"
-               fi
-               
-               starter="$( sed -e :a -e 's/^.\{1,'$width'\}$/&./;ta' <<< $print_string )"
-               if [[ -z $( grep '^/' <<< $application ) && -n $location ]] || [[ -d $application || -f $application ]];then
-                       if [[ -n $location ]];then
-                               finisher=" $location"
-                       else
-                               finisher=" Present"
-                       fi
-               else
-                       finisher=" Missing"
-                       missing_items="$missing_items$separator$application:$package"
-                       separator=' '
-               fi
-               
-               echo "$starter$finisher"
-       done
-       echo 
-       if [[ -n $missing_items ]];then
-               echo "The following $type are missing from your system:"
-               for item in $missing_items
-               do
-                       application=$( cut -d ':' -f 1 <<< $item )
-                       if [[ $type == 'applications' ]];then
-                               echo
-                               package=$( cut -d ':' -f 2 <<< $item )
-                               package_deb=$( cut -d '~' -f 1 <<< $package )
-                               package_pacman=$( cut -d '~' -f 2 <<< $package )
-                               package_rpm=$( cut -d '~' -f 3 <<< $package )
-                               echo "Application: $application"
-                               print_lines_basic "0" "" "To add to your system, install the proper distribution package for your system:"
-                               print_lines_basic "0" "" "Debian/Ubuntu:^$package_deb^:: Arch Linux:^$package_pacman^:: Redhat/Fedora/Suse:^$package_rpm"
-                       elif [[ $type == 'directories' ]];then
-                               echo "Directory: $application"
-                       elif [[ $type == 'files' ]];then
-                               echo "File: $application"
-                       fi
-               done
-               if [[ $item_string == 'System directory' ]];then
-                       print_lines_basic "0" "" "These directories are created by the kernel, so don't worry if they are not present."
-               fi
-       else
-               echo "All the $( cut -d ' ' -f 1 <<< $item_string | sed -e 's/Re/re/' -e 's/Sy/sy/' ) $type are present."
-       fi
-       echo $Line
+
+# args: 1 - desktop/app command for --version; 2 - search string; 
+# 3 - space print number; 4 - [optional] version arg: -v, version, etc
+# 5 - [optional] exit first find 0/1; 6 - [optional] 0/1 stderr output
+sub set_basics {
+       ### LOCALIZATION - DO NOT CHANGE! ###
+       # set to default LANG to avoid locales errors with , or .
+       # Make sure every program speaks English.
+       $ENV{'LANG'}='C';
+       $ENV{'LC_ALL'}='C';
+       # remember, perl uses the opposite t/f return as shell!!!
+       $b_irc = ( system('tty >/dev/null') ) ? 1 : 0;
+       # print "birc: $b_irc\n";
+       $b_display = ( $ENV{'DISPLAY'} ) ? 1 : 0;
+       $b_root = ( $ENV{'HOME'} eq '/root' ) ? 1 : 0;
+       $dl{'dl'} = 'curl';
+       $dl{'curl'} = 1;
+       $dl{'tiny'} = 1; # note: two modules needed, tested for in set_downloader
+       $dl{'wget'} = 1;
+       $dl{'fetch'} = 1;
+       $client{'console-irc'} = 0;
+       $client{'dcop'} = (check_program('dcop')) ? 1 : 0;
+       $client{'qdbus'} = (check_program('qdbus')) ? 1 : 0;
+       $client{'konvi'} = 0;
+       $client{'name'} = '';
+       $client{'name-print'} = '';
+       $client{'su-start'} = ''; # shows sudo/su
+       $client{'version'} = '';
+       $colors{'default'} = 2;
 }
 
-#### -------------------------------------------------------------------
-#### print / output cleaners
-#### -------------------------------------------------------------------
+# args: $1 - default OR override default cols max integer count. $_[0]
+# is the display width override.
+sub set_display_width {
+       my ($width) = @_;
+       if ( $width eq 'live' ){
+               ## sometimes tput will trigger an error (mageia) if irc client
+               if ( ! $b_irc ){
+                       if ( check_program('tput') ) {
+                               # trips error if use qx()...
+                               chomp($size{'term'}=qx{tput cols});
+                               chomp($size{'term-lines'}=qx{tput lines});
+                               $size{'term-cols'} = $size{'term'};
+                       }
+                       # print "tc: $size{'term'} cmc: $size{'console'}\n";
+                       # double check, just in case it's missing functionality or whatever
+                       if ( $size{'term'} == 0 || $size{'term'} !~ /\d/ ){ 
+                               $size{'term'}=80;
+                               # we'll be using this for terminal dimensions later so don't set default.
+                               # $size{'term-lines'}=100;
+                       }
+               }
+               # this lets you set different size for in or out of display server
+               # if ( ! $b_running_in_display && $configs{'COLS_MAX_NO_DISPLAY'} != 0 ){
+               #       $size{'console'}=$configs{'COLS_MAX_NO_DISPLAY'};
+               # }
+               # term_cols is set in top globals, using tput cols
+               # print "tc: $size{'term'} cmc: $size{'console'}\n";
+               if ( $size{'term'} < $size{'console'} ){
+                       $size{'console'}=$size{'term'};
+               }
+               # adjust, some terminals will wrap if output cols == term cols
+               $size{'console'}=( $size{'console'} - 2 );
+               # echo cmc: $size{'console'}
+               # comes after source for user set stuff
+               if ( ! $b_irc ){
+                       $size{'max'}=$size{'console'};
+               }
+               else {
+                       $size{'max'}=$size{'irc'};
+               }
+       }
+       else {
+               $size{'max'}=$width;
+       }
+       # print "tc: $size{'term'} cmc: $size{'console'} cm: $size{'max'}\n";
+}
 
-# inxi speaks through here. When run by Konversation script alias mode, uses DCOP
-# for dcop to work, must use 'say' operator, AND colors must be evaluated by echo -e
-# note: dcop does not seem able to handle \n so that's being stripped out and replaced with space.
-print_screen_output()
-{
-       eval $LOGFS
-       # the double quotes are needed to avoid losing whitespace in data when certain output types are used
-       # trim off whitespace at end
-       local print_data="$( echo -e "$1" )" 
-
-       # just using basic debugger stuff so you can tell which thing is printing out the data. This
-       # should help debug kde 4 konvi issues when that is released into sid, we'll see. Turning off
-       # the redundant debugger output which as far as I can tell does exactly nothing to help debugging.
-       if [[ $DEBUG -gt 5 ]];then
-               if [[ $KONVI -eq 1 ]];then
-                       # 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'"
-                       print_data="KP-$KONVI: $print_data"
-               elif [[ $KONVI -eq 2 ]];then
-                       # echo "konvi='$KONVI' saying : '$print_data'"
-                       print_data="KP-$KONVI: $print_data"
-               else
-                       # echo "printing out: '$print_data'"
-                       print_data="P: $print_data"
-               fi
-       fi
-       if [[ $KONVI -eq 1 && $B_DCOP == 'true' ]]; then ## dcop Konversation (<= 1.1 (qt3))
-               # 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" "$print_data"
-       elif [[ $KONVI -eq 3 && $B_QDBUS == 'true' ]]; then ## dbus Konversation (> 1.2 (qt4))
-               qdbus org.kde.konversation /irc say "$DCSERVER" "$DCTARGET" "$print_data"
-#      elif [[ $IRC_CLIENT == 'X-Chat' ]]; then
-#              qdbus org.xchat.service print "$print_data\n"
-       else
-               # the -n is needed to avoid double spacing of output in terminal
-               echo -ne "$print_data\n"
-       fi
-       eval $LOGFE
-}
-
-## this handles all verbose line construction with indentation/line starter
-## args: $1 - null (, actually: " ") or line starter; $2 - line content
-create_print_line()
-{
-       eval $LOGFS
-       # convoluted, yes, but it works to trim spaces off end
-       local line=${2%${2##*[![:space:]]}}
-       printf "${C1}%-${INDENT}s${C2} %s" "$1" "$line${CN}"
-       eval $LOGFE
+# only for dev/debugging BSD 
+sub set_fake_tools {
+       $system_files{'dmesg-boot'} = '/var/run/dmesg.boot' if $b_fake_dboot;
+       $alerts{'pciconf'} = ({'action' => 'use'}) if $b_fake_pciconf;
+       $alerts{'sysctl'} = ({'action' => 'use'}) if $b_fake_sysctl;
+       if ($b_fake_usbdevs ){
+               $alerts{'usbdevs'} = ({'action' => 'use'});
+               $alerts{'lsusb'} = ({
+               'action' => 'missing',
+               'missing' => 'Required program lsusb not available',
+               });
+       }
 }
 
-# this removes newline and pipes.
-# args: $1 - string to clean
-remove_erroneous_chars()
-{
-       eval $LOGFS
-       ## RS is input record separator
-       ## gsub is substitute;
-       gawk '
-       BEGIN {
-               RS=""
-       }
-       {
-               gsub(/\n$/,"")         ## (newline; end of string) with (nothing)
-               gsub(/\n/," ");        ## (newline) with (space)
-               gsub(/^ *| *$/, "")    ## (pipe char) with (nothing)
-               gsub(/  +/, " ")       ## ( +) with (space)
-               gsub(/ [ ]+/, " ")     ## ([ ]+) with (space)
-               gsub(/^ +| +$/, "")    ## (pipe char) with (nothing)
-               printf $0
-       }' "$1"      ## prints (returns) cleaned input
-       eval $LOGFE
+# NOTE: most tests internally are against !$bsd_type
+sub set_os {
+       @uname = uname();
+       $os = lc($uname[0]);
+       $cpu_arch = lc($uname[-1]);
+       if ($cpu_arch =~ /arm|aarch/){$b_arm = 1}
+       elsif ($cpu_arch =~ /mips/) {$b_mips = 1}
+       # aarch32 mips32 intel/amd handled in cpu
+       if ($cpu_arch =~ /(armv[1-7]|32|sparc_v9)/){
+               $bits_sys = 32;
+       }
+       elsif ($cpu_arch =~ /(alpha|64)/){
+               $bits_sys = 64;
+       }
+       if ( $os =~ /(bsd|dragonfly|darwin)/ ){
+               if ( $os =~ /openbsd/ ){
+                       $os = 'openbsd';
+               }
+               elsif ($os =~ /darwin/){
+                       $os = 'darwin';
+               }
+               if ($os =~ /kfreebsd/){
+                       $bsd_type = 'debian-bsd';
+               }
+               else {
+                       $bsd_type = $os;
+               }
+       }
 }
 
-#### -------------------------------------------------------------------
-#### parameter handling, print usage functions.
-#### -------------------------------------------------------------------
+# This data is hard set top of program but due to a specific project's
+# foolish idea that ignoring the FSH totally is somehow a positive step
+# forwards for free software, we also have to padd the results with PATH.
+sub set_path {
+       # Extra path variable to make execute failures less likely, merged below
+       my (@path);
+       @paths = qw(/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/X11R6/bin);
+       @path = split /:/, $ENV{'PATH'} if $ENV{'PATH'};
+       # print "paths: @paths\nPATH: $ENV{'PATH'}\n";
+       # Create a difference of $PATH and $extra_paths and add that to $PATH:
+       foreach my $id (@path) {
+               if ( !(grep { /^$id$/ } @paths) && $id !~ /(game)/ ){
+                       push @paths, $id;
+               }
+       }
+       # print "paths: @paths\n";
+}
 
-# Get the parameters. Note: standard options should be lower case, advanced or testing, upper
-# args: $1 - full script startup args: $@
-get_parameters()
-{
-       eval $LOGFS
-       local opt='' downloader_test='' debug_data_type='' weather_flag='wW:' 
-       local use_short='true' # this is needed to trigger short output, every v/d/F/line trigger sets this false
+sub set_sep {
+       if ( $b_irc ){
+               # too hard to read if no colors, so force that for users on irc
+               if ($colors{'scheme'} == 0 ){
+                       $sep{'s1'} = $sep{'s1-console'};
+                       $sep{'s2'} = $sep{'s2-console'};
+               }
+               else {
+                       $sep{'s1'} = $sep{'s1-irc'};
+                       $sep{'s2'} = $sep{'s2-irc'};
+               }
+       }
+       else {
+               $sep{'s1'} = $sep{'s1-console'};
+               $sep{'s2'} = $sep{'s2-console'};
+       }
+}
 
-       # if distro maintainers don't want the weather feature disable it
-       if [[ $B_ALLOW_WEATHER == 'false' ]];then
-               weather_flag=''
-       fi
-       if [[ $1 == '--version' ]];then
-               print_version_info
-               exit 0
-       elif [[ $1 == '--help' ]];then
-               show_options
-               exit 0
-       elif [[ $1 == '--recommends' ]];then
-               check_recommends_user_output
-               exit 0
-       # the short form only runs if no args output args are used
-       # no need to run through these if there are no args
-       # reserved for future use: -g for extra Graphics; -m for extra Machine; -d for extra Disk
-       elif [[ -n $1 ]];then
-               while getopts AbBc:CdDfFGhHiIlmMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt
-               do
-                       case $opt in
-                       A)      B_SHOW_AUDIO='true'
-                               use_short='false'
-                               ;;
-                       b)      use_short='false'
-                               B_SHOW_BASIC_CPU='true'
-                               B_SHOW_BASIC_RAID='true'
-                               B_SHOW_DISK_TOTAL='true'
-                               B_SHOW_GRAPHICS='true'
-                               B_SHOW_INFO='true'
-                               B_SHOW_MACHINE='true'
-                               B_SHOW_BATTERY='true'
-                               B_SHOW_NETWORK='true'
-                               B_SHOW_SYSTEM='true'
-                               ;;
-                       B)      B_SHOW_BATTERY_FORCED='true'
-                               B_SHOW_BATTERY='true'
-                               use_short='false'
-                               ;;
-                       c)      if [[ $OPTARG =~ ^[0-9][0-9]?$ ]];then
-                                       case $OPTARG in
-                                               99)
-                                                       B_RUN_COLOR_SELECTOR='true'
-                                                       COLOR_SELECTION='global'
-                                                       ;;
-                                               98)
-                                                       B_RUN_COLOR_SELECTOR='true'
-                                                       COLOR_SELECTION='irc-console'
-                                                       ;;
-                                               97)
-                                                       B_RUN_COLOR_SELECTOR='true'
-                                                       COLOR_SELECTION='irc-virtual-terminal'
-                                                       ;;
-                                               96)
-                                                       B_RUN_COLOR_SELECTOR='true'
-                                                       COLOR_SELECTION='irc'
-                                                       ;;
-                                               95)
-                                                       B_RUN_COLOR_SELECTOR='true'
-                                                       COLOR_SELECTION='virtual-terminal'
-                                                       ;;
-                                               94)
-                                                       B_RUN_COLOR_SELECTOR='true'
-                                                       COLOR_SELECTION='console'
-                                                       ;;
-                                               *)      
-                                                       B_COLOR_SCHEME_SET='true'
-                                                       ## note: not sure about this, you'd think user values should be overridden, but
-                                                       ## we'll leave this for now
-                                                       if [[ -z $COLOR_SCHEME ]];then
-                                                               set_color_scheme "$OPTARG"
-                                                       fi
-                                                       ;;
-                                       esac
-                               else
-                                       error_handler 3 "$OPTARG"
-                               fi
-                               ;;
-                       C)      B_SHOW_CPU='true'
-                               use_short='false'
-                               ;;
-                       d)      B_SHOW_DISK='true'
-                               B_SHOW_FULL_OPTICAL='true'
-                               use_short='false'
-                               # error_handler 20 "-d has been replaced by -b"
-                               ;;
-                       D)      B_SHOW_DISK='true'
-                               use_short='false'
-                               ;;
-                       f)      B_SHOW_CPU='true'
-                               B_CPU_FLAGS_FULL='true'
-                               use_short='false'
-                               ;;
-                       F)      # B_EXTRA_DATA='true'
-                               B_SHOW_ADVANCED_NETWORK='true'
-                               B_SHOW_AUDIO='true'
-                               # B_SHOW_BASIC_OPTICAL='true'
-                               B_SHOW_CPU='true'
-                               B_SHOW_DISK='true'
-                               B_SHOW_GRAPHICS='true'
-                               B_SHOW_INFO='true'
-                               B_SHOW_MACHINE='true'
-                               B_SHOW_BATTERY='true'
-                               B_SHOW_NETWORK='true'
-                               B_SHOW_PARTITIONS='true'
-                               B_SHOW_RAID='true'
-                               B_SHOW_SENSORS='true'
-                               B_SHOW_SYSTEM='true'
-                               use_short='false'
-                               ;;
-                       G)      B_SHOW_GRAPHICS='true'
-                               use_short='false'
-                               ;;
-                       i)      B_SHOW_IP='true'
-                               B_SHOW_NETWORK='true'
-                               B_SHOW_ADVANCED_NETWORK='true'
-                               use_short='false'
-                               ;;
-                       I)      B_SHOW_INFO='true'
-                               use_short='false'
-                               ;;
-                       l)      B_SHOW_LABELS='true'
-                               B_SHOW_PARTITIONS='true'
-                               use_short='false'
-                               ;;
-                       m)      B_SHOW_MEMORY='true'
-                               use_short='false'
-                               ;;
-                       M)      B_SHOW_MACHINE='true'
-                               B_SHOW_BATTERY='true'
-                               use_short='false'
-                               ;;
-                       n)      B_SHOW_ADVANCED_NETWORK='true'
-                               B_SHOW_NETWORK='true'
-                               use_short='false'
-                               ;;
-                       N)      B_SHOW_NETWORK='true'
-                               use_short='false'
-                               ;;
-                       o)      B_SHOW_UNMOUNTED_PARTITIONS='true'
-                               use_short='false'
-                               ;;
-                       p)      B_SHOW_PARTITIONS_FULL='true'
-                               B_SHOW_PARTITIONS='true'
-                               use_short='false'
-                               ;;
-                       P)      B_SHOW_PARTITIONS='true'
-                               use_short='false'
-                               ;;
-                       r)      B_SHOW_REPOS='true'
-                               use_short='false'
-                               ;;
-                       R)      B_SHOW_RAID='true'
-                               # it turns out only users with mdraid software installed will have raid,
-                               # so unless -R is explicitly called, blank -b/-F/-v6 and less output will not show
-                               # error if file is missing.
-                               B_SHOW_RAID_R='true'
-                               use_short='false'
-                               ;;
-                       s)      B_SHOW_SENSORS='true'
-                               use_short='false'
-                               ;;
-                       S)      B_SHOW_SYSTEM='true'
-                               use_short='false'
-                               ;;
-                       t)      if [[ $OPTARG =~ ^(c|m|cm|mc)([1-9]|1[0-9]|20)?$ ]];then
-                                       use_short='false'
-                                       if [[ -n $( grep -E '[0-9]+' <<< $OPTARG ) ]];then
-                                               PS_COUNT=$( sed 's/[^0-9]//g' <<< $OPTARG )
-                                       fi
-                                       if [[ -n $( grep 'c' <<< $OPTARG ) ]];then
-                                               B_SHOW_PS_CPU_DATA='true'
-                                       fi
-                                       if [[ -n $( grep 'm' <<< $OPTARG ) ]];then
-                                               B_SHOW_PS_MEM_DATA='true'
-                                       fi
-                               else
-                                       error_handler 13 "$OPTARG"
-                               fi
-                               ;;
-                       u)      B_SHOW_UUIDS='true'
-                               B_SHOW_PARTITIONS='true'
-                               use_short='false'
-                               ;;
-                       v)      if [[ $OPTARG =~ ^[0-9][0-9]?$ && $OPTARG -le $VERBOSITY_LEVELS ]];then
-                                       if [[ $OPTARG -ge 1 ]];then
-                                               use_short='false'
-                                               B_SHOW_BASIC_CPU='true'
-                                               B_SHOW_DISK_TOTAL='true'
-                                               B_SHOW_GRAPHICS='true'
-                                               B_SHOW_INFO='true'
-                                               B_SHOW_SYSTEM='true'
-                                       fi
-                                       if [[ $OPTARG -ge 2 ]];then
-                                               B_SHOW_BASIC_DISK='true'
-                                               B_SHOW_BASIC_RAID='true'
-                                               B_SHOW_BATTERY='true'
-                                               B_SHOW_MACHINE='true'
-                                               B_SHOW_NETWORK='true'
-                                       fi
-                                       if [[ $OPTARG -ge 3 ]];then
-                                               B_SHOW_ADVANCED_NETWORK='true'
-                                               B_SHOW_CPU='true'
-                                               B_EXTRA_DATA='true'
-                                       fi
-                                       if [[ $OPTARG -ge 4 ]];then
-                                               B_SHOW_DISK='true'
-                                               B_SHOW_PARTITIONS='true'
-                                       fi
-                                       if [[ $OPTARG -ge 5 ]];then
-                                               B_SHOW_AUDIO='true'
-                                               B_SHOW_BASIC_OPTICAL='true'
-                                               B_SHOW_MEMORY='true'
-                                               B_SHOW_SENSORS='true'
-                                               B_SHOW_LABELS='true'
-                                               B_SHOW_UUIDS='true'
-                                               B_SHOW_RAID='true'
-                                       fi
-                                       if [[ $OPTARG -ge 6 ]];then
-                                               B_SHOW_FULL_OPTICAL='true'
-                                               B_SHOW_PARTITIONS_FULL='true'
-                                               B_SHOW_UNMOUNTED_PARTITIONS='true'
-                                               B_EXTRA_EXTRA_DATA='true'
-                                       fi
-                                       if [[ $OPTARG -ge 7 ]];then
-                                               B_EXTRA_EXTRA_EXTRA_DATA='true'
-                                               B_SHOW_IP='true'
-                                               B_SHOW_RAID_R='true'
-                                       fi
-                               else
-                                       error_handler 4 "$OPTARG"
-                               fi
-                               ;;
-                       U)      if [[ $B_ALLOW_UPDATE == 'true' ]];then
-                                       script_self_updater "$SCRIPT_DOWNLOAD" 'svn server' "$opt"
-                               else
-                                       error_handler 17 "-$opt"
-                               fi
-                               ;;
-                       V)      print_version_info
-                               exit 0
-                               ;;
-                       w)      B_SHOW_WEATHER=true
-                               use_short='false'
-                               ;;
-                       W)      ALTERNATE_WEATHER_LOCATION=$( sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'  <<< $OPTARG )
-                               if [[ -n $( grep -Esi '([^,]+,.+|[0-9-]+)' <<< $ALTERNATE_WEATHER_LOCATION ) ]];then
-                                       B_SHOW_WEATHER=true
-                                       use_short='false'
-                               else
-                                       error_handler 18 "-$opt: '$OPTARG'" "city,state OR latitude,longitude OR postal/zip code."
-                               fi
-                               ;;
-                       # this will trigger either with x, xx, xxx or with Fx but not with xF
-                       x)      if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
-                                       B_EXTRA_EXTRA_EXTRA_DATA='true'
-                               elif [[ $B_EXTRA_DATA == 'true' ]];then
-                                       B_EXTRA_EXTRA_DATA='true'
-                               else
-                                       B_EXTRA_DATA='true'
-                               fi
-                               ;;
-                       y)      if [[ -z ${OPTARG//[0-9]/} && $OPTARG -ge 80 ]];then
-                                       set_display_width "$OPTARG"
-                               else
-                                       error_handler 21 "$OPTARG"
-                               fi
-                               ;;
-                       z)      B_OUTPUT_FILTER='true'
-                               ;;
-                       Z)      B_OVERRIDE_FILTER='true'
-                               ;;
-                       h)      show_options
-                               exit 0
-                               ;;
-                       H)      show_options 'full'
-                               exit 0
-                               ;;
-                       ## debuggers and testing tools
-                       %)      B_HANDLE_CORRUPT_DATA='true'
-                               ;;
-                       @)      if [[ -n $( grep -E "^([1-9]|1[0-5])$" <<< $OPTARG ) ]];then
-                                       DEBUG=$OPTARG
-                                       if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then
-                                               B_UPLOAD_DEBUG_DATA='true'
-                                       fi
-                                       exec 2>&1
-                                       # switch on logging only for -@ 8-10
-                                       case $OPTARG in
-                                               8|9|10)
-                                                       if [[ $OPTARG -eq 10 ]];then
-                                                               B_LOG_COLORS='true'
-                                                       elif [[ $OPTARG -eq 9 ]];then           
-                                                               B_LOG_FULL_DATA='true'
-                                                       fi
-                                                       B_USE_LOGGING='true'
-                                                       # pack the logging data for evals function start/end
-                                                       LOGFS=$LOGFS_STRING
-                                                       LOGFE=$LOGFE_STRING
-                                                       create_rotate_logfiles # create/rotate logfiles before we do anything else
-                                                       ;;
-                                               11|12|13|14|15)
-                                                       case $OPTARG in
-                                                               11)
-                                                                       debug_data_type='sys'
-                                                                       ;;
-                                                               12)
-                                                                       debug_data_type='xorg'
-                                                                       ;;
-                                                               13)
-                                                                       debug_data_type='disk'
-                                                                       ;;
-                                                               14)
-                                                                       debug_data_type='all'
-                                                                       ;;
-                                                               15)
-                                                                       debug_data_type='all'
-                                                                       B_DEBUG_I='true'
-                                                                       ;;
-                                                       esac
-                                                       initialize_data
-                                                       debug_data_collector $debug_data_type
-                                                       ;;
-                                       esac
-                               else
-                                       error_handler 9 "$OPTARG"
-                               fi
-                               ;;
-                       !)      # test for various supported methods
-                               case $OPTARG in
-                                       1)      B_TESTING_1='true'
-                                               ;;
-                                       2)      B_TESTING_2='true'
-                                               ;;
-                                       3)      B_TESTING_1='true'
-                                               B_TESTING_2='true'
-                                               ;;
-                                       1[0-6]|http*)
-                                               if [[ $B_ALLOW_UPDATE == 'true' ]];then
-                                                       case $OPTARG in
-                                                               10)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_DEV" 'dev server' "$opt $OPTARG"
-                                                                       ;;
-                                                               11)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_1" 'svn: branch one server' "$opt $OPTARG"
-                                                                       ;;
-                                                               12)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_2" 'svn: branch two server' "$opt $OPTARG"
-                                                                       ;;
-                                                               13)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_3" 'svn: branch three server' "$opt $OPTARG"
-                                                                       ;;
-                                                               14)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server' "$opt $OPTARG"
-                                                                       ;;
-                                                               15)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_BSD" 'svn: branch bsd server' "$opt $OPTARG"
-                                                                       ;;
-                                                               16)
-                                                                       script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_GNUBSD" 'svn: branch gnubsd server' "$opt $OPTARG"
-                                                                       ;;
-                                                               http*)
-                                                                       script_self_updater "$OPTARG" 'alt server' "$opt <http...>"
-                                                                       ;;
-                                                       esac
-                                               else
-                                                       error_handler 17 "-$opt $OPTARG"
-                                               fi
-                                               ;;
-                                       30)
-                                               B_IRC='false'
-                                               ;;
-                                       31)
-                                               B_SHOW_HOST='false'
-                                               ;;
-                                       32)
-                                               B_SHOW_HOST='true'
-                                               ;;
-                                       33)
-                                               B_FORCE_DMIDECODE='true'
-                                               ;;
-                                       ftp*)
-                                               ALTERNATE_FTP="$OPTARG"
-                                               ;;
-                                       # for weather function, allows user to set an alternate weather location
-                                       location=*)
-                                               error_handler 19 "-$opt location=" "-W"
-                                               ;;
-                                       *)      error_handler 11 "$OPTARG"
-                                               ;;
-                               esac
-                               ;;
-                       *)      error_handler 7 "$1"
-                               ;;
-                       esac
-               done
-       fi
-       ## this must occur here so you can use the debugging flag to show errors
-       ## Reroute all error messages to the bitbucket (if not debugging)
-       if [[ $DEBUG -eq 0 ]];then
-               exec 2>/dev/null
-       fi
-       #((DEBUG)) && exec 2>&1 # This is for debugging konversation
-
-       # after all the args have been processed, if no long output args used, run short output
-       if [[ $use_short == 'true' ]];then
-               B_SHOW_SHORT_OUTPUT='true'
-       fi
-       # just in case someone insists on using -zZ
-       if [[ $B_OVERRIDE_FILTER == 'true' ]];then
-               B_OUTPUT_FILTER='false'
-       fi
-       # change basic to full if user requested it or if arg overrides it
-       if [[ $B_SHOW_RAID == 'true' && $B_SHOW_BASIC_RAID == 'true' ]];then
-               B_SHOW_BASIC_RAID='false'
-       fi
+sub set_user_paths {
+       my ( $b_conf, $b_data );
+       # this needs to be set here because various options call the parent 
+       # initialize function directly.
+       $self_path = $0;
+       $self_path =~ s/[^\/]+$//;
+       # print "0: $0 sp: $self_path\n";
        
-       
-       eval $LOGFE
+       if ( defined $ENV{'XDG_CONFIG_HOME'} && $ENV{'XDG_CONFIG_HOME'} ){
+               $user_config_dir=$ENV{'XDG_CONFIG_HOME'};
+               $b_conf=1;
+       }
+       elsif ( -d "$ENV{'HOME'}/.config" ){
+               $user_config_dir="$ENV{'HOME'}/.config";
+               $b_conf=1;
+       }
+       else {
+               $user_config_dir="$ENV{'HOME'}/.$self_name";
+       }
+       if ( defined $ENV{'XDG_DATA_HOME'} && $ENV{'XDG_DATA_HOME'} ){
+               $user_data_dir="$ENV{'XDG_DATA_HOME'}/$self_name";
+               $b_data=1;
+       }
+       elsif ( -d "$ENV{'HOME'}/.local/share" ){
+               $user_data_dir="$ENV{'HOME'}/.local/share/$self_name";
+               $b_data=1;
+       }
+       else {
+               $user_data_dir="$ENV{'HOME'}/.$self_name";
+       }
+       # note, this used to be created/checked in specific instance, but we'll just do it
+       # universally so it's done at script start.
+       if ( ! -d $user_data_dir ){
+               mkdir $user_data_dir;
+               # system "echo", "Made: $user_data_dir";
+       }
+       if ( $b_conf && -f "$ENV{'HOME'}/.$self_name/$self_name.conf" ){
+               #system 'mv', "-f $ENV{'HOME'}/.$self_name/$self_name.conf", $user_config_dir;
+               # print "WOULD: Moved $self_name.conf from $ENV{'HOME'}/.$self_name to $user_config_dir\n";
+       }
+       if ( $b_data && -d "$ENV{'HOME'}/.$self_name" ){
+               #system 'mv', '-f', "$ENV{'HOME'}/.$self_name/*", $user_data_dir;
+               #system 'rm', '-Rf', "$ENV{'HOME'}/.$self_name";
+               # print "WOULD: Moved data dir $ENV{'HOME'}/.$self_name to $user_data_dir\n";
+       }
+       $log_file="$user_data_dir/$self_name.log";
+       #system 'echo', "$ENV{'HOME'}/.$self_name/* $user_data_dir";
+       # print "scd: $user_config_dir sdd: $user_data_dir \n";
 }
 
-## print out help menu, not including Testing or Debugger stuff because it's not needed
-show_options()
-{
-       local color_scheme_count=$(( ${#A_COLOR_SCHEMES[@]} - 1 ))
-       local partition_string='partition' partition_string_u='Partition'
-       
-       if [[ $B_IRC == 'true' ]];then
-               print_screen_output "Sorry, you can't run the help option in an IRC client."
-               exit 1
-       fi
-       if [[ -n $BSD_TYPE ]];then
-               partition_string='slice'
-               partition_string_u='Slice'
-       fi
-       # print_lines_basic "0" "" ""
-       # print_lines_basic "1" "" ""
-       # print_lines_basic "2" "" ""
-       # print_screen_output " "
-       print_lines_basic "0" "" "$SCRIPT_NAME supports the following options. You can combine them, or list them one by one. Examples: $SCRIPT_NAME^-v4^-c6 OR $SCRIPT_NAME^-bDc^6. If you start $SCRIPT_NAME with no arguments, it will show the short form."
-       print_screen_output " "
-       print_lines_basic "0" "" "The following options if used without -F, -b, or -v will show just option line(s): A, B, C, D, G, I, M, N, P, R, S, f, i, m, n, o, p, l, u, r, s, t - you can use these alone or together to show just the line(s) you want to see. If you use them with -v^[level], -b or -F, it will show the full output for that line along with the output for the chosen verbosity level."
-       print_screen_output "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
-       print_screen_output "Output Control Options:"
-       print_lines_basic "1" "-A" "Audio/sound card information."
-       print_lines_basic "1" "-b" "Basic output, short form. Like $SCRIPT_NAME^-v^2, only minus hard disk names ."
-       print_lines_basic "1" "-B" "Battery info, shows charge, condition, plus extra information (if battery present)."
-       print_lines_basic "1" "-c" "Color schemes. Scheme number is required. Color selectors run a color selector option prior to $SCRIPT_NAME starting which lets you set the config file value for the selection."
-       print_lines_basic "1" "" "Supported color schemes: 0-$color_scheme_count Example:^$SCRIPT_NAME^-c^11"
-       print_lines_basic "1" "" "Color selectors for each type display (NOTE: irc and global only show safe color set):"
-#      print_screen_output "    Supported color schemes: 0-$color_scheme_count Example: $SCRIPT_NAME -c 11"
-#      print_screen_output "    Color selectors for each type display (NOTE: irc and global only show safe color set):"
-       print_lines_basic "2" "94" "Console, out of X"
-       print_lines_basic "2" "95" "Terminal, running in X - like xTerm"
-       print_lines_basic "2" "96" "Gui IRC, running in X - like Xchat, Quassel, Konversation etc."
-       print_lines_basic "2" "97" "Console IRC running in X - like irssi in xTerm"
-       print_lines_basic "2" "98" "Console IRC not in  X"
-       print_lines_basic "2" "99" "Global - Overrides/removes all settings. Setting specific removes global."
-       print_lines_basic "1" "-C" "CPU output, including per CPU clockspeed and max CPU speed (if available)."
-       print_lines_basic "1" "-d" "Optical drive data. Same as -Dd. See also -x and -xx."
-       print_lines_basic "1" "-D" "Full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB. See also -x and -xx. Disk total used percentage includes swap partition size(s)."
-       print_lines_basic "1" "-f" "All cpu flags, triggers -C. Not shown with -F to avoid spamming. ARM cpus show 'features'."
-       print_lines_basic "1" "-F" "Full output for $SCRIPT_NAME. Includes all Upper Case line letters, plus -s and -n. Does not show extra verbose options like -d -f -l -m -o -p -r -t -u -x"
-       print_lines_basic "1" "-G" "Graphic card information (card, display server type/version, resolution, glx renderer, version)."
-       print_lines_basic "1" "-i" "Wan IP address, and shows local interfaces (requires ifconfig 
-       network tool). Same as -Nni. Not shown with -F for user security reasons, you shouldn't paste your local/wan IP."
-       print_lines_basic "1" "-I" "Information: processes, uptime, memory, irc client (or shell type), $SCRIPT_NAME version."
-       print_lines_basic "1" "-l" "$partition_string_u labels. Default: short $partition_string -P. For full -p output, use: -pl (or -plu)."
-       print_lines_basic "1" "-m" "Memory (RAM) data. Physical system memory array(s), capacity, how many devices (slots) supported, and individual memory devices (sticks of memory etc). For devices, shows device locator, size, speed, type (like: DDR3). Also see -x, -xx, -xxx"
-       print_lines_basic "1" "-M" "Machine data. Motherboard, Bios, and if present, System Builder (Like Lenovo). Older systems/kernels without the required /sys data can use dmidecode instead, run as root. Dmidecode can be forced with -! 33"
-       print_lines_basic "1" "-n" "Advanced Network card information. Same as -Nn. Shows interface, speed, mac id, state, etc."
-       print_lines_basic "1" "-N" "Network card information. With -x, shows PCI BusID, Port number."
-       print_lines_basic "1" "-o" "Unmounted $partition_string information (includes UUID and LABEL if available). Shows file system type if you have file installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^<username>^ALL^=^NOPASSWD:^/usr/bin/file^"
-       print_lines_basic "1" "-p" "Full $partition_string information (-P plus all other detected ${partition_string}s)."
-       print_lines_basic "1" "-P" "Basic $partition_string information (shows what -v^4 would show, but without extra data). Shows, if detected: / /boot /home /tmp /usr /var. Use -p to see all mounted ${partition_string}s."
-       print_lines_basic "1" "-r" "Distro repository data. Supported repo types: APT; PACMAN; PISI; PORTAGE; PORTS (BSDs); SLACKPKG; URPMQ; YUM; ZYPP."
-       print_lines_basic "1" "-R" "RAID data. Shows RAID devices, states, levels, and components, and extra data with -x/-xx. md-raid: If device is resyncing, shows resync progress line as well."
-       print_lines_basic "1" "-s" "Sensors output (if sensors installed/configured): mobo/cpu/gpu temp; detected fan speeds. Gpu temp only for Fglrx/Nvidia drivers. Nvidia shows screen number for > 1 screens."
-       print_lines_basic "1" "-S" "System information: host name, kernel, desktop environment (if in X), distro"
-       print_lines_basic "1" "-t" "Processes. Requires extra options: c^(cpu) m^(memory) cm^(cpu+memory). If followed by numbers 1-20, shows that number of processes for each type (default:^$PS_COUNT; if in irc, max:^5): -t^cm10"
-       print_lines_basic "1" "" "Make sure to have no space between letters and numbers (-t^cm10 - right, -t^cm^10 - wrong)."
-       print_lines_basic "1" "-u" "$partition_string_u UUIDs. Default: short $partition_string -P. For full -p output, use: -pu (or -plu)."
-       print_lines_basic "1" "-v" "Script verbosity levels. Verbosity level number is required. Should not be used with -b or -F"
-       print_lines_basic "1" "" "Supported levels: 0-$VERBOSITY_LEVELS Example: $SCRIPT_NAME^-v^4"
-       print_lines_basic "2" "0" "Short output, same as: $SCRIPT_NAME"
-       print_lines_basic "2" "1" "Basic verbose, -S + basic CPU + -G + basic Disk + -I."
-       print_lines_basic "2" "2" "Networking card (-N), Machine (-M) data, if present, Battery (-B), basic hard disk data (names only), and, if present, basic raid (devices only, and if inactive, notes that). similar to: $SCRIPT_NAME^-b"
-       print_lines_basic "2" "3" "Advanced CPU (-C), battery, network (-n) data, and switches on -x advanced data option."
-       print_lines_basic "2" "4" "$partition_string_u size/filled data (-P) for (if present): /, /home, /var/, /boot. Shows full disk data (-D)."
-       print_lines_basic "2" "5" "Audio card (-A); sensors^(-s), memory/ram^(-m), $partition_string label^(-l) and UUID^(-u), short form of optical drives, standard raid data (-R)."
-       print_lines_basic "2" "6" "Full $partition_string (-p), unmounted $partition_string (-o), optical drive (-d), full raid; triggers -xx."
-       print_lines_basic "2" "7" "Network IP data (-i); triggers -xxx."
-       
-       # if distro maintainers don't want the weather feature disable it
-       if [[ $B_ALLOW_WEATHER == 'true' ]];then
-               print_lines_basic "1" "-w" "Local weather data/time. To check an alternate location, see: -W^<location>. For extra weather data options see -x, -xx, and -xxx."
-               print_lines_basic "1" "-W" "<location> Supported options for <location>: postal code; city, state/country; latitude, longitude. Only use if you want the weather somewhere other than the machine running $SCRIPT_NAME. Use only ascii characters, replace spaces in city/state/country names with '+'. Example:^$SCRIPT_NAME^-W^new+york,ny"
-       fi
-       print_lines_basic "1" "-x" "Adds the following extra data (only works with verbose or line output, not short form):"
-       print_lines_basic "2" "-B" "Vendor/model, status (if available)"
-       print_lines_basic "2" "-C" "CPU Flags, Bogomips on Cpu;"
-       print_lines_basic "2" "-d" "Extra optical drive data; adds rev version to optical drive."
-       print_lines_basic "2" "-D" "Hdd temp with disk data if you have hddtemp installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^<username>^ALL^=^NOPASSWD:^/usr/sbin/hddtemp"
-       print_lines_basic "2" "-G" "Direct rendering status for Graphics (in X)."
-       print_lines_basic "2" "-G" "(for single gpu, nvidia driver) screen number gpu is running on."
-       print_lines_basic "2" "-i" "IPv6 as well for LAN interface (IF) devices."
-       print_lines_basic "2" "-I" "System GCC, default. With -xx, also show other installed GCC versions. If running in console, not in IRC client, shows shell version number, if detected. Init/RC Type and runlevel (if available)."
-       print_lines_basic "2" "-m" "Part number; Max memory module size (if available)."
-       print_lines_basic "2" "-N -A" "Version/port(s)/driver version (if available) for Network/Audio;"
-       print_lines_basic "2" "-N -A -G" "Network, audio, graphics, shows PCI Bus ID/Usb ID number of card."
-       print_lines_basic "2" "-R" "md-raid: Shows component raid id. Adds second RAID Info line: raid level; report on drives (like 5/5); blocks; chunk size; bitmap (if present). Resync line, shows blocks synced/total blocks. zfs-raid:    Shows raid array full size; available size; portion allocated to RAID"
-       print_lines_basic "2" "-S" "Desktop toolkit if avaliable (GNOME/XFCE/KDE only); Kernel gcc version"
-       print_lines_basic "2" "-t" "Memory use output to cpu (-xt c), and cpu use to memory (-xt m)."
-       if [[ $B_ALLOW_WEATHER == 'true' ]];then
-               print_lines_basic "2" "-w -W" "Wind speed and time zone (-w only)."
-       fi
-       print_lines_basic "1" "-xx" "Show extra, extra data (only works with verbose or line output, not short form):"
-       print_lines_basic "2" "-A" "Chip vendor:product ID for each audio device."
-       print_lines_basic "2" "-B" "serial number, voltage (if available)."
-       print_lines_basic "2" "-C" "Minimum CPU speed, if available."
-       print_lines_basic "2" "-D" "Disk serial number."
-       print_lines_basic "2" "-G" "Chip vendor:product ID for each video card."
-       print_lines_basic "2" "-I" "Other detected installed gcc versions (if present). System default runlevel. Adds parent program (or tty) for shell info if not in IRC (like Konsole or Gterm). Adds Init/RC (if found) version number."
-       print_lines_basic "2" "-m" "Manufacturer, Serial Number, single/double bank (if found)."
-       print_lines_basic "2" "-M" "Chassis information, bios rom size (dmidecode only), if data for either is available."
-       print_lines_basic "2" "-N" "Chip vendor:product ID for each nic."
-       print_lines_basic "2" "-R" "md-raid: Superblock (if present); algorythm, U data. Adds system info line (kernel support,read ahead, raid events). If present, adds unused device line. Resync line, shows progress bar."
-       print_lines_basic "2" "-S" "Display manager (dm) in desktop output, if in X (like kdm, gdm3, lightdm)."
-       if [[ $B_ALLOW_WEATHER == 'true' ]];then
-               print_lines_basic "2" "-w -W" "Humidity, barometric pressure."
-       fi
-       print_lines_basic "2" "-@ 11-14" "Automatically uploads debugger data tar.gz file to ftp.techpatterns.com. EG: $SCRIPT_NAME^-xx@14"
-       print_lines_basic "1" "-xxx" "Show extra, extra, extra data (only works with verbose or line output, not short form):"
-       print_lines_basic "2" "-B" "chemistry, cycles, location (if available)."
-       print_lines_basic "2" "-m" "Width of memory bus, data and total (if present and greater than data); Detail, if present, for Type; module voltage, if available."
-       print_lines_basic "2" "-S" "Panel/shell information in desktop output, if in X (like gnome-shell, cinnamon, mate-panel)."
-       if [[ $B_ALLOW_WEATHER == 'true' ]];then
-               print_lines_basic "2" "-w -W" "Location (uses -z/irc filter), weather observation time, wind chill, heat index, dew point (shows extra lines for data where relevant)."
-       fi
-       print_lines_basic "1" "-y" "Required extra option: integer, 80 or greater. Set the output line width max. Overrides IRC/Terminal settings or actual widths. If used with -h, put -y option first. Example:^inxi^-y^130"
-       print_lines_basic "1" "-z" "Security filters for IP/Mac addresses, location, user home directory name. Default on for irc clients."
-       print_lines_basic "1" "-Z" "Absolute override for output filters. Useful for debugging networking issues in irc for example."
-       print_screen_output " "
-       print_screen_output "Additional Options:"
-       print_lines_basic "4" "-h --help" "This help menu."
-       print_lines_basic "4" "-H" "This help menu, plus developer options. Do not use dev options in normal operation!"
-       print_lines_basic "4" "--recommends" "Checks $SCRIPT_NAME application dependencies + recommends, and directories, then shows what package(s) you need to install to add support for that feature. "
-       if [[ $B_ALLOW_UPDATE == 'true' ]];then
-               print_lines_basic "4" "-U" "Auto-update script. Will also install/update man page. Note: if you installed as root, you must be root to update, otherwise user is fine. Man page installs require root user mode."
-       fi
-       print_lines_basic "4" "-V --version" "$SCRIPT_NAME version information. Prints information then exits."
-       print_screen_output " "
-       print_screen_output "Debugging Options:"
-       print_lines_basic "1" "-%" "Overrides defective or corrupted data."
-       print_lines_basic "1" "-@" "Triggers debugger output. Requires debugging level 1-14 (8-10 - logging of data). Less than 8 just triggers $SCRIPT_NAME debugger output on screen."
-       print_lines_basic "2" "1-7" "On screen debugger output"
-       print_lines_basic "2" "8" "Basic logging"
-       print_lines_basic "2" "9" "Full file/sys info logging"
-       print_lines_basic "2" "10" "Color logging."
-       print_lines_basic "1" "" "The following create a tar.gz file of system data, plus collecting the inxi output to file. To automatically upload debugger data tar.gz file to ftp.techpatterns.com: inxi^-xx@^<11-14>"
-       print_lines_basic "1" "" "For alternate ftp upload locations: Example:^inxi^-!^ftp.yourserver.com/incoming^-xx@^14"
-       print_lines_basic "2" "11" "With data file of xiin read of /sys."
-       print_lines_basic "2" "12" "With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc."
-       print_lines_basic "2" "13" "With data from dev, disks, ${partition_string}s, etc., plus xiin data file."
-       print_lines_basic "2" "14" "Everything, full data collection."
-       print_screen_output " "
-       print_screen_output "Advanced Options:"
-       print_lines_basic "1" "-! 31" "Turns off hostname in output. Useful if showing output from servers etc."
-       print_lines_basic "1" "-! 32" "Turns on hostname in output. Overrides global B_SHOW_HOST='false'"
-       print_lines_basic "1" "-! 33" "Forces use of dmidecode data instead of /sys where relevant (-M)."
-       
-       if [[ $1 == 'full' ]];then
-               print_screen_output " "
-               print_screen_output "Developer and Testing Options (Advanced):"
-               print_lines_basic "1" "-! 1" "Sets testing flag B_TESTING_1='true' to trigger testing condition 1."
-               print_lines_basic "1" "-! 2" "Sets testing flag B_TESTING_2='true' to trigger testing condition 2."
-               print_lines_basic "1" "-! 3" "Sets flags B_TESTING_1='true' and B_TESTING_2='true'."
-               if [[ $B_ALLOW_UPDATE == 'true' ]];then
-                       print_lines_basic "1" "-! 10" "Triggers an update from the primary dev download server instead of svn."
-                       print_lines_basic "1" "-! 11" "Triggers an update from svn branch one - if present, of course."
-                       print_lines_basic "1" "-! 12" "Triggers an update from svn branch two - if present, of course."
-                       print_lines_basic "1" "-! 13" "Triggers an update from svn branch three - if present, of course."
-                       print_lines_basic "1" "-! 14" "Triggers an update from svn branch four - if present, of course."
-                       print_lines_basic "1" "-! 15" "Triggers an update from svn branch BSD - if present, of course."
-                       print_lines_basic "1" "-! 16" "Triggers an update from svn branch GNUBSD - if present, of course."
-                       print_lines_basic "1" "-! " "<http://......> Triggers an update from whatever server you list."
-                       print_lines_basic "1" "" "Example: inxi^-!^http://yourserver.com/testing/inxi"
-               fi
-               print_lines_basic "1" "-! " "<ftp.......> Changes debugging data ftp upload location to whatever you enter here. Only used together with -xx@^11-14, and must be used in front of that."
-               print_lines_basic "1" "" "Example: inxi^-!^ftp.yourserver.com/incoming^-xx@^14"
-       fi
-       print_screen_output " "
-}
-
-# uses $TERM_COLUMNS to set width using $COLS_MAX as max width
-# IMPORTANT: minimize use of subshells here or the output is too slow
-# IMPORTANT: each text chunk must be a continuous line, no line breaks. For anyone who uses a 
-# code editor that can't do visual (not hard coded) line wrapping, upgrade to one that can.
-# args: $1 - 0 1 2 3 4 for indentation level; $2 -line starter, like -m; $3 - content of block.
-print_lines_basic()
-{
-       local line_width=$COLS_MAX
-       local print_string='' indent_inner='' indent_full='' indent_x='' 
-       local indent_working='' indent_working_full=''
-       local line_starter='' line_1_starter='' line_x_starter='' 
-       # note: to create a padded string below
-       local fake_string=' ' temp_count='' line_count='' spacer=''
-       local indent_main=6 indent_x='' b_indent_x='true' 
-       
-       case $1 in
-               # for no options, start at left edge
-               0)      indent_full=0
-                       line_1_starter=''
-                       line_x_starter=''
-                       b_indent_x='false'
-                       ;;
-               1)      indent_full=$indent_main
-                       temp_count=${#2}
-                       if [[ $temp_count -le $indent_full ]];then
-                               indent_working=$indent_full
-                       else
-                               indent_working=$temp_count #$(( $temp_count + 1 ))
-                       fi
-                       line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )"
-                       ;;
-               # first left pad 2 and 3, then right pad them
-               2)      indent_full=$(( $indent_main + 6 ))
-                       indent_inner=3
-                       temp_count=${#2}
-                       if [[ $temp_count -le $indent_inner ]];then
-                               indent_working=$indent_inner
-                               #indent_working_full=$indent_full
-                       else
-                               indent_working=$(( $temp_count + 1 ))
-                               #indent_working_full=$(( $indent_full - $indent_inner - 1 ))
-                       fi
-                       line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )"
-                       line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" <<< "$line_1_starter" )"
-                       ;;
-               3)      indent_full=$(( $indent_main + 8 ))
-                       indent_inner=3
-                       temp_count=${#2}
-                       if [[ $temp_count -le $indent_inner ]];then
-                               indent_working=$indent_inner
-                       else
-                               indent_working=$(( $temp_count + 1 ))
-                       fi
-                       line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )"
-                       line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" <<< "$line_1_starter" )"
-                       ;;
-               # for long options
-               4)      indent_full=$(( $indent_main + 8 ))
-                       temp_count=${#2}
-                       if [[ $temp_count -lt $indent_full ]];then
-                               indent_working=$indent_full
-                       else
-                               indent_working=$temp_count #$(( $temp_count + 1 ))
-                       fi
-                       line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )"
-                       ;;
-       esac
-       
-       if [[ $b_indent_x == 'true' ]];then
-               indent_x=$(( $indent_full + 1 ))
-               line_x_starter="$(printf "%${indent_x}s" '')"
-       fi
-       
-       line_count=$(( $line_width - $indent_full ))
-       
-       # bash loop is slow, only run this if required
-       if [[ ${#3} -gt $line_count ]];then
-               for word in $3
-               do
-                       temp_string="$print_string$spacer$word"
-                       spacer=' '
-                       if [[ ${#temp_string} -lt $line_count ]];then
-                               print_string=$temp_string # lose any white space start/end
-                               # echo -n $(( $line_width - $indent_full ))
-                       else
-                               if [[ -n $line_1_starter ]];then
-                                       line_starter="$line_1_starter"
-                                       line_1_starter=''
-                               else
-                                       line_starter="$line_x_starter"
-                               fi
-                               # clean up forced connections, ie, stuff we don't want wrapping
-                               print_string=${print_string//\^/ }
-                               print_screen_output "$line_starter$print_string"
-                               print_string="$word$spacer" # needed to handle second word on new line
-                               temp_string=''
-                               spacer=''
-                       fi
-               done
-       else
-               # echo no loop
-               print_string=$3
-       fi
-       # print anything left over
-       if [[ -n $print_string ]];then
-               if [[ -n $line_1_starter ]];then
-                       line_starter="$line_1_starter"
-                       line_1_starter=''
-               else
-                       line_starter="$line_x_starter"
-               fi
-               print_string=${print_string//\^/ }
-               print_screen_output "$line_starter$print_string"
-       fi
-}
-# print_lines_basic '1' '-m' 'let us teest this string and lots more and stuff and more stuff and x is wy and z is x and fred is dead and gus is alive an yes we have to go now'
-# print_lines_basic '2' '7' 'and its substring this string and lots more and stuff and more stuff and x is wy and z is x and fred is dead and gus is alive an yes we have to go now'
-# print_lines_basic '2' '12' 'and its sss substring'
-# print_lines_basic '3' '12' 'and its sss substring this string and lots more and stuff and more stuff and x is wy and z is x and fred is dead and gus is alive an yes we have to go now'
-# exit
-
-## print out version information for -V/--version
-print_version_info()
-{
-       # if not in PATH could be either . or directory name, no slash starting
-       local script_path=$SCRIPT_PATH script_symbolic_start=''
-       if [[ $script_path == '.' ]];then
-               script_path=$( pwd )
-       elif [[ -z $( grep '^/' <<< "$script_path" ) ]];then
-               script_path="$( pwd )/$script_path"
-       fi
-       # handle if it's a symbolic link, rare, but can happen with script directories in irc clients
-       # which would only matter if user starts inxi with -! 30 override in irc client
-       if [[ -L $script_path/$SCRIPT_NAME ]];then
-               script_symbolic_start=$script_path/$SCRIPT_NAME
-               script_path=$( readlink $script_path/$SCRIPT_NAME )
-               script_path=$( dirname $script_path )
-       fi
-       local last_modified=$( parse_version_data 'date' ) 
-       local year_modified=$( gawk '{print $NF}' <<< "$last_modified" )
-       
-       print_screen_output "$SCRIPT_NAME $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER ($last_modified)"
-       if [[ $B_IRC == 'false' ]];then
-               print_screen_output "Program Location: $script_path"
-               if [[ -n $script_symbolic_start ]];then
-                       print_screen_output "Started via symbolic link: $script_symbolic_start"
-               fi
-               print_lines_basic "0" "" "Website:^https://github.com/smxi/inxi^or^http://smxi.org/"
-               print_lines_basic "0" "" "IRC:^irc.oftc.net channel:^#smxi"
-               print_lines_basic "0" "" "Forums:^http://techpatterns.com/forums/forum-33.html"
-               print_screen_output " "
-               print_lines_basic "0" "" "$SCRIPT_NAME - the universal, portable, system information tool for console and irc."
-               print_screen_output " "
-               print_lines_basic "0" "" "This program started life as a fork of Infobash 3.02: Copyright^(C)^2005-2007^Michiel^de^Boer^a.k.a.^locsmif."
-               print_lines_basic "0" "" "Subsequent changes and modifications (after Infobash 3.02): Copyright^(C)^2008-${year_modified%%-*}^Harald^Hope,^Scott^Rogers,^aka^h2^&trash80."
-               print_screen_output " "
-               print_lines_basic "0" "" "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 the Free Software Foundation; either version 3 of the License, or (at your option) any later version. (http://www.gnu.org/licenses/gpl.html)"
-       fi
+# args: 1: set|hash key to return either null or path
+sub system_files {
+       my ($file) = @_;
+       if ( $file eq 'set'){
+               %files = (
+               'asound-cards' => '/proc/asound/cards',
+               'asound-modules' => '/proc/asound/modules',
+               'asound-version' => '/proc/asound/version',
+               'cpuinfo' => '/proc/cpuinfo',
+               'dmesg-boot' => '/var/run/dmesg.boot',
+               'lsb-release' => '/etc/lsb-release',
+               'mdstat' => '/proc/mdstat',
+               'meminfo' => '/proc/meminfo',
+               'modules' => '/proc/modules',
+               'mounts' => '/proc/mounts',
+               'os-release' => '/etc/os-release',
+               'partitions' => '/proc/partitions',
+               'scsi' => '/proc/scsi/scsi',
+               'version' => '/proc/version',
+               'xorg-log' => '/var/log/Xorg.0.log'
+               );
+               foreach ( keys %files ){
+                       $system_files{$_} = ( -e $files{$_} ) ? $files{$_} : '';
+               }
+               if ( ! $system_files{'xorg-log'} && check_program('xset') ){
+                       my $data = qx(xset q 2>/dev/null);
+                       foreach ( split /\n/, $data){
+                               if ($_ =~ /Log file/i){
+                                       $system_files{'xorg-log'} = get_piece($_,3);
+                                       last;
+                               }
+                       }
+               }
+       }
+       else {
+               return $system_files{$file};
+       }
 }
 
 ########################################################################
-#### MAIN FUNCTIONS
+#### UTILITIES
 ########################################################################
 
 #### -------------------------------------------------------------------
-#### initial startup stuff
+#### COLORS
 #### -------------------------------------------------------------------
 
-# Determine where inxi was run from, set IRC_CLIENT and IRC_CLIENT_VERSION
-get_start_client()
-{
-       eval $LOGFS
-       local Irc_Client_Path='' irc_client_path_lower='' non_native_konvi='' i=''
-       local B_Non_Native_App='false' pppid='' App_Working_Name=''
-       local b_qt4_konvi='false' ps_parent=''
-
-       if [[ $B_IRC == 'false' ]];then
-               IRC_CLIENT='Shell'
-               unset IRC_CLIENT_VERSION
-       # elif [[ -n $PPID ]];then
-       elif [[ -n $PPID && -f /proc/$PPID/exe ]];then
-               if [[ $B_OVERRIDE_FILTER != 'true' ]];then
-                       B_OUTPUT_FILTER='true'
-               fi
-               Irc_Client_Path=$( readlink /proc/$PPID/exe )
-               # Irc_Client_Path=$( ps -p $PPID | gawk '!/[[:space:]]*PID/ {print $5}'  )
-               # echo $( ps -p $PPID )
-               irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< $Irc_Client_Path )
-               App_Working_Name=${irc_client_path_lower##*/}
-               # handles the xchat/sh/bash/dash cases, and the konversation/perl cases, where clients
-               # report themselves as perl or unknown shell. IE:  when konversation starts inxi
-               # from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc
-               # note: perl can report as: perl5.10.0, so it needs wildcard handling
-               case $App_Working_Name in
-                       # bsd will never use this section
-                       bash|dash|sh|python*|perl*)     # We want to know who wrapped it into the shell or perl.
-                               if [[ $BSD_TYPE != 'bsd' ]];then
-                                       pppid=$( ps -p $PPID -o ppid --no-headers 2>/dev/null | gawk '{print $NF}' )
-                               else
-                                       # without --no-headers we need the second line
-                                       pppid=$( ps -p $PPID -o ppid 2>/dev/null | gawk '$1 ~ /^[0-9]+/ {print $5}' )
-                               fi
-                               if [[ -n $pppid && -f /proc/$pppid/exe ]];then
-                                       Irc_Client_Path="$( readlink /proc/$pppid/exe )"
-                                       irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< $Irc_Client_Path )
-                                       App_Working_Name=${irc_client_path_lower##*/}
-                                       B_Non_Native_App='true'
-                               fi
-                               ;;
-               esac
-               # sets version number if it can find it
-               get_irc_client_version
-       else
-               ## lets look to see if qt4_konvi is the parent.  There is no direct way to tell, so lets infer it.
-               ## because $PPID does not work with qt4_konvi, the above case does not work
-               if [[ $B_OVERRIDE_FILTER != 'true' ]];then
-                       B_OUTPUT_FILTER='true'
-               fi
-               b_qt4_konvi=$( is_this_qt4_konvi )
-               if [[ $b_qt4_konvi == 'true' ]];then
-                       KONVI=3
-                       IRC_CLIENT='Konversation'
-                       IRC_CLIENT_VERSION=" $( konversation -v | gawk '
-                               /Konversation:/ {
-                                       for ( i=2; i<=NF; i++ ) {
-                                               if (i == NF) {
-                                                       print $i
-                                               }
-                                               else {
-                                                       printf $i" "
-                                               }
-                                       }
-                                       exit
-                               }' )"
-               else
-                       # this should handle certain cases where it's ssh or some other startup tool
-                       # that falls through all the other tests. Also bsd irc clients will land here
-                       if [[ $BSD_TYPE != 'bsd' ]];then
-                               App_Working_Name=$(ps -p $PPID --no-headers 2>/dev/null | gawk '{print $NF}' )
-                       else
-                               # without --no-headers we need the second line
-                               App_Working_Name=$(ps -p $PPID 2>/dev/null | gawk '$1 ~ /^[0-9]+/ {print $5}' )
-                       fi
-                       
-                       if [[ -n $App_Working_Name ]];then
-                               Irc_Client_Path=$App_Working_Name
-                               irc_client_path_lower=$( tr '[A-Z]' '[a-z]' <<< $Irc_Client_Path )
-                               App_Working_Name=${irc_client_path_lower##*/}
-                               B_Non_Native_App='false'
-                               get_irc_client_version
-                               if [[ -z $IRC_CLIENT ]];then
-                                       IRC_CLIENT=$App_Working_Name
-                               fi
-                       else
-                               IRC_CLIENT="PPID=\"$PPID\" - empty?"
-                               unset IRC_CLIENT_VERSION
-                       fi
-               fi
-       fi
-
-       log_function_data "IRC_CLIENT: $IRC_CLIENT :: IRC_CLIENT_VERSION: $IRC_CLIENT_VERSION :: PPID: $PPID"
-       eval $LOGFE
-}
-# note: all variables set in caller so no need to pass
-get_irc_client_version()
-{
-       local file_data=''
-       # replacing loose detection with tight detection, bugs will be handled with app names
-       # as they appear.
-       case $App_Working_Name in
-               # check for shell first
-               bash|dash|sh)
-                       unset IRC_CLIENT_VERSION
-                       IRC_CLIENT="Shell wrapper"
-                       ;;
-               # now start on irc clients, alphabetically
-               bitchx)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk '
-                       /Version/ {
-                               a=tolower($2)
-                               gsub(/[()]|bitchx-/,"",a)
-                               print a
-                               exit
-                       }
-                       $2 == "version" {
-                               a=tolower($3)
-                               sub(/bitchx-/,"",a)
-                               print a
-                               exit
-                       }' )"
-                       B_CONSOLE_IRC='true'
-                       IRC_CLIENT="BitchX"
-                       ;;
-               finch)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $2
-                       }' )"
-                       B_CONSOLE_IRC='true'
-                       IRC_CLIENT="Finch"
-                       ;;
-               gaim)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $2
-                       }' )"
-                       IRC_CLIENT="Gaim"
-                       ;;
-               hexchat)
-                       # the hexchat author decided to make --version/-v return a gtk dialogue box, lol...
-                       # so we need to read the actual config file for hexchat. Note that older hexchats
-                       # used xchat config file, so test first for default, then legacy. Because it's possible
-                       # for this file to be use edited, doing some extra checks here.
-                       if [[ -f ~/.config/hexchat/hexchat.conf ]];then
-                               file_data="$( cat ~/.config/hexchat/hexchat.conf )"
-                       elif [[ -f  ~/.config/hexchat/xchat.conf ]];then
-                               file_data="$( cat ~/.config/hexchat/xchat.conf )"
-                       fi
-                       if [[ -n $file_data ]];then
-                               IRC_CLIENT_VERSION=$( gawk '
-                               BEGIN {
-                                       IGNORECASE=1
-                                       FS="="
-                               }
-                               /^[[:space:]]*version/ {
-                                       # get rid of the space if present
-                                       gsub(/[[:space:]]*/, "", $2 )
-                                       print $2
-                                       exit # usually this is the first line, no point in continuing
-                               }' <<< "$file_data" )
-                               
-                               IRC_CLIENT_VERSION=" $IRC_CLIENT_VERSION"
-                       else
-                               IRC_CLIENT_VERSION=' N/A'
-                       fi
-                       IRC_CLIENT="HexChat"
-                       ;;
-               ircii)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $3
-                       }' )"
-                       B_CONSOLE_IRC='true'
-                       IRC_CLIENT="ircII"
-                       ;;
-               irssi|irssi-text)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $2
-                       }' )"
-                       B_CONSOLE_IRC='true'
-                       IRC_CLIENT="Irssi"
-                       ;;
-               konversation) ## konvi < 1.2 (qt4)
-                       # this is necessary to avoid the dcop errors from starting inxi as a /cmd started script
-                       if [[ $B_Non_Native_App == 'true' ]];then  ## true negative is confusing
-                               KONVI=2
-                       else # if native app
-                               KONVI=1
-                       fi
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk '
-                       /Konversation:/ {
-                               for ( i=2; i<=NF; i++ ) {
-                                       if (i == NF) {
-                                               print $i
-                                       }
-                                       else {
-                                               printf $i" "
-                                       }
-                               }
-                               exit
-                       }' )"
-                       T=($IRC_CLIENT_VERSION)
-                       if [[ ${T[0]} == *+* ]];then
-                               # < Sho_> locsmif: The version numbers of SVN versions look like this:
-                               #         "<version number of last release>+ #<build number", i.e. "1.0+ #3177" ...
-                               #         for releases we remove the + and build number, i.e. "1.0" or soon "1.0.1"
-                               IRC_CLIENT_VERSION=" CVS $IRC_CLIENT_VERSION"
-                               T2="${T[0]/+/}"
-                       else
-                               IRC_CLIENT_VERSION=" ${T[0]}"
-                               T2="${T[0]}"
-                       fi
-                       # Remove any dots except the first, and make sure there are no trailing zeroes,
-                       T2=$( echo "$T2" | gawk '{
-                               sub(/\./, " ")
-                               gsub(/\./, "")
-                               sub(/ /, ".")
-                               printf("%g\n", $0)
-                       }' )
-                       # 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.
-                       if [[ $T2 -lt 1 ]];then
-                               DCOPOBJ="Konversation"
-                       fi
-                       IRC_CLIENT="Konversation"
-                       ;;
-               kopete)
-                       IRC_CLIENT_VERSION=" $( kopete -v | gawk '
-                       /Kopete:/ {
-                               print $2
-                               exit
-                       }' )"
-                       IRC_CLIENT="Kopete"
-                       ;;
-               kvirc)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v 2>&1 | gawk '{
-                               for ( i=2; i<=NF; i++) {
-                                       if ( i == NF ) {
-                                               print $i
-                                       }
-                                       else {
-                                               printf $i" "
-                                       }
-                               }
-                               exit
-                               }' )"
-                       IRC_CLIENT="KVIrc"
-                       ;;
-               pidgin)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $2
-                       }' )"
-                       IRC_CLIENT="Pidgin"
-                       ;;
-               # possible failure of wildcard so make it explicit
-               quassel*)
-                       # sample: quassel -v
-                       ## Qt: 4.5.0 - in Qt4 the output came from src/common/quassel.cpp
-                       # KDE: 4.2.65 (KDE 4.2.65 (KDE 4.3 >= 20090226))
-                       # Quassel IRC: v0.4.0 [+60] (git-22effe5)
-                       # note: early < 0.4.1 quassels do not have -v
-                       ## Qt: 5: sample: quassel -v
-                       # quassel v0.13-pre (0.12.0+5 git-8e2f578)
-                       # because in Qt5 the internal CommandLineParser is used 
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v 2>/dev/null | gawk '
-                       BEGIN {
-                               IGNORECASE=1
-                               clientVersion=""
-                       }
-                       # qt 4 -v syntax
-                       /^Quassel IRC:/ {
-                               clientVersion = $3
-                       }
-                       # qt 5 -v syntax
-                       /^quassel\s[v]?[0-9]/ {
-                               clientVersion = $2
-                       }
-                       END {
-                               # this handles pre 0.4.1 cases with no -v
-                               if ( clientVersion == "" ) {
-                                       clientVersion = "(pre v0.4.1)?"
-                               }
-                               print clientVersion
-                       }' )"
-                       # now handle primary, client, and core. quasselcore doesn't actually
-                       # handle scripts with exec, but it's here just to be complete
-                       case $App_Working_Name in
-                               quassel)
-                                       IRC_CLIENT="Quassel [M]"
-                                       ;;
-                               quasselclient)
-                                       IRC_CLIENT="Quassel"
-                                       ;;
-                               quasselcore)
-                                       IRC_CLIENT="Quassel (core)"
-                                       ;;
-                       esac
-                       ;;
-               gribble|limnoria|supybot)
-                       IRC_CLIENT_VERSION=" $( get_program_version 'supybot' '^Supybot' '2' )"
-                       if [[ -n $IRC_CLIENT_VERSION ]];then
-                               if [[ -n ${IRC_CLIENT_VERSION/*gribble*/} || $App_Working_Name == 'gribble' ]];then
-                                       IRC_CLIENT="Gribble"
-                               elif [[ -n ${IRC_CLIENT_VERSION/*limnoria*/} || $App_Working_Name == 'limnoria' ]];then
-                                       IRC_CLIENT="Limnoria"
-                               else
-                                       IRC_CLIENT="Supybot"
-                               fi
-                       fi
-                       ;;
-               weechat|weechat-curses)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v ) "
-                       B_CONSOLE_IRC='true'
-                       IRC_CLIENT="WeeChat"
-                       ;;
-               xchat-gnome)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $2
-                       }' )"
-                       IRC_CLIENT="X-Chat-Gnome"
-                       ;;
-               xchat)
-                       IRC_CLIENT_VERSION=" $( $Irc_Client_Path -v | gawk 'NR == 1 {
-                               print $2
-                       }' )"
-                       IRC_CLIENT="X-Chat"
-                       ;;
-               # then do some perl type searches, do this last since it's a wildcard search
-               perl*|ksirc|dsirc)
-                       unset IRC_CLIENT_VERSION
-                       # KSirc is one of the possibilities now. KSirc is a wrapper around dsirc, a perl client
-                       get_cmdline $PPID
-                       for (( i=0; i <= $CMDL_MAX; i++ ))
-                       do
-                               case ${A_CMDL[i]} in
-                                       *dsirc*)
-                                       IRC_CLIENT="KSirc"
-                                       # Dynamic runpath detection is too complex with KSirc, because KSirc is started from
-                                       # kdeinit. /proc/<pid of the grandparent of this process>/exe is a link to /usr/bin/kdeinit
-                                       # with one parameter which contains parameters separated by spaces(??), first param being KSirc.
-                                       # Then, KSirc runs dsirc as the perl irc script and wraps around it. When /exec is executed,
-                                       # dsirc is the program that runs inxi, therefore that is the parent process that we see.
-                                       # You can imagine how hosed I am if I try to make inxi find out dynamically with which path
-                                       # KSirc was run by browsing up the process tree in /proc. That alone is straightjacket material.
-                                       # (KSirc sucks anyway ;)
-                                       IRC_CLIENT_VERSION=" $( ksirc -v | gawk '
-                                       /KSirc:/ {
-                                               print $2
-                                               exit
-                                       }' )"
-                                       break
-                                       ;;
-                               esac
-                       done
-                       B_CONSOLE_IRC='true'
-                       set_perl_python_client_data "$App_Working_Name"
-                       ;;
-               python*)
-                       # B_CONSOLE_IRC='true' # are there even any python type console irc clients? check.
-                       set_perl_python_client_data "$App_Working_Name"
-                       ;;
-               # then unset, set unknown data
-               *)      
-                       IRC_CLIENT="Unknown : ${Irc_Client_Path##*/}"
-                       unset IRC_CLIENT_VERSION
-                       ;;
-       esac
-       if [[ $SHOW_IRC -lt 2 ]];then
-               unset IRC_CLIENT_VERSION
-       fi
-}
-
-# args: $1 - App_Working_Name
-set_perl_python_client_data()
-{
-       if [[ -z $IRC_CLIENT_VERSION ]];then
-               local version=''
-               # this is a hack to try to show konversation if inxi is running but started via /cmd
-               # OR via script shortcuts, both cases in fact now
-               if [[  $B_RUNNING_IN_DISPLAY == 'true' && -z ${Ps_aux_Data/*konversation*/} ]];then
-                       IRC_CLIENT='Konversation'
-                       version=$( get_program_version 'konversation' '^konversation' '2' )
-                       B_CONSOLE_IRC='false'
-               ## NOTE: supybot only appears in ps aux using 'SHELL' command; the 'CALL' command
-               ## gives the user system irc priority, and you don't see supybot listed, so use SHELL
-               elif [[ $B_RUNNING_IN_DISPLAY == 'false' && -z ${Ps_aux_Data/*supybot*/} ]];then
-                       version=$( get_program_version 'supybot' '^Supybot' '2' )
-                       if [[ -n $version ]];then
-                               IRC_CLIENT_VERSION=" $version"
-                               if [[ -z ${version/*gribble*/} ]];then
-                                       IRC_CLIENT='Gribble'
-                               elif [[ -z ${version/*limnoria*/} ]];then
-                                       IRC_CLIENT='Limnoria'
-                               else
-                                       IRC_CLIENT='Supybot'
-                               fi
-                       else
-                               IRC_CLIENT='Supybot'
-                       # currently all use the same actual app name, this will probably change.
-                       fi
-                       B_CONSOLE_IRC='true'
-               else
-                       IRC_CLIENT="Unknown $1 client"
-               fi
-               if [[ -n $version ]];then
-                       IRC_CLIENT_VERSION=" $version"
-               fi
-       fi
+## arg: 1 - the type of action, either integer, count, or full
+sub get_color_scheme {
+       my ($type) = @_;
+       eval $start if $b_log;
+       my @color_schemes = (
+       [qw(EMPTY EMPTY EMPTY )],
+       [qw(NORMAL NORMAL NORMAL )],
+       # for dark OR light backgrounds
+       [qw(BLUE NORMAL NORMAL)],
+       [qw(BLUE RED NORMAL )],
+       [qw(CYAN BLUE NORMAL )],
+       [qw(DCYAN NORMAL NORMAL)],
+       [qw(DCYAN BLUE NORMAL )],
+       [qw(DGREEN NORMAL NORMAL )],
+       [qw(DYELLOW NORMAL NORMAL )],
+       [qw(GREEN DGREEN NORMAL )],
+       [qw(GREEN NORMAL NORMAL )],
+       [qw(MAGENTA NORMAL NORMAL)],
+       [qw(RED NORMAL NORMAL)],
+       # for light backgrounds
+       [qw(BLACK DGREY NORMAL)],
+       [qw(DBLUE DGREY NORMAL )],
+       [qw(DBLUE DMAGENTA NORMAL)],
+       [qw(DBLUE DRED NORMAL )],
+       [qw(DBLUE BLACK NORMAL)],
+       [qw(DGREEN DYELLOW NORMAL )],
+       [qw(DYELLOW BLACK NORMAL)],
+       [qw(DMAGENTA BLACK NORMAL)],
+       [qw(DCYAN DBLUE NORMAL)],
+       # for dark backgrounds
+       [qw(WHITE GREY NORMAL)],
+       [qw(GREY WHITE NORMAL)],
+       [qw(CYAN GREY NORMAL )],
+       [qw(GREEN WHITE NORMAL )],
+       [qw(GREEN YELLOW NORMAL )],
+       [qw(YELLOW WHITE NORMAL )],
+       [qw(MAGENTA CYAN NORMAL )],
+       [qw(MAGENTA YELLOW NORMAL)],
+       [qw(RED CYAN NORMAL)],
+       [qw(RED WHITE NORMAL )],
+       [qw(BLUE WHITE NORMAL)],
+       # miscellaneous
+       [qw(RED BLUE NORMAL )],
+       [qw(RED DBLUE NORMAL)],
+       [qw(BLACK BLUE NORMAL)],
+       [qw(BLACK DBLUE NORMAL)],
+       [qw(NORMAL BLUE NORMAL)],
+       [qw(BLUE MAGENTA NORMAL)],
+       [qw(DBLUE MAGENTA NORMAL)],
+       [qw(BLACK MAGENTA NORMAL)],
+       [qw(MAGENTA BLUE NORMAL)],
+       [qw(MAGENTA DBLUE NORMAL)],
+       );
+       if ($type eq 'count' ){
+               return scalar @color_schemes;
+       }
+       if ($type eq 'full' ){
+               return @color_schemes;
+       }
+       else {
+               return @{$color_schemes[$type]};
+               # print Dumper $color_schemes[$scheme_nu];
+       }
+       eval $end if $b_log;
 }
 
-## try to infer the use of Konversation >= 1.2, which shows $PPID improperly
-## no known method of finding Kovni >= 1.2 as parent process, so we look to see if it is running,
-## and all other irc clients are not running. As of 2014-03-25 this isn't used in my cases
-is_this_qt4_konvi()
-{
-       local konvi_qt4_client='' konvi_dbus_exist='' konvi_pid='' konvi_home_dir='' 
-       local konvi='' b_is_qt4=''
+sub set_color_scheme {
+       eval $start if $b_log;
+       my ($scheme) = @_;
+       $colors{'scheme'} = $scheme;
+       my $index = ( $b_irc ) ? 1 : 0; # defaults to non irc
        
-       # fringe cases can throw error, always if untested app, use 2>/dev/null after testing if present
-       if [[ $B_QDBUS == 'true' ]];then
-               konvi_dbus_exist=$( qdbus 2>/dev/null | grep "org.kde.konversation" )
-       fi
-       # sabayon uses /usr/share/apps/konversation as path
-       if [[ -n $konvi_dbus_exist ]] && [[ -e /usr/share/kde4/apps/konversation || -e  /usr/share/apps/konversation ]]; then
-               konvi_pid=$( ps -A | gawk 'BEGIN{IGNORECASE=1} /konversation/ { print $1 }' ) 
-               konvi_home_dir=$( readlink /proc/$konvi_pid/exe )
-               konvi=$( echo $konvi_home_dir | sed "s/\// /g" )
-               konvi=($konvi)
+       # NOTE: qw(...) kills the escape, it is NOT the same as using 
+       # Literal "..", ".." despite docs saying it is.
+       my %color_palette = (
+       'EMPTY' => [ '', '' ],
+       'DGREY' => [ "\e[1;30m", "\x0314" ],
+       'BLACK' => [ "\e[0;30m", "\x0301" ],
+       'RED' => [ "\e[1;31m", "\x0304" ],
+       'DRED' => [ "\e[0;31m", "\x0305" ],
+       'GREEN' => [ "\e[1;32m", "\x0309" ],
+       'DGREEN' => [ "\e[0;32m", "\x0303" ],
+       'YELLOW' => [ "\e[1;33m", "\x0308" ],
+       'DYELLOW' => [ "\e[0;33m", "\x0307" ],
+       'BLUE' => [ "\e[1;34m", "\x0312" ],
+       'DBLUE' => [ "\e[0;34m", "\x0302" ],
+       'MAGENTA' => [ "\e[1;35m", "\x0313" ],
+       'DMAGENTA' => [ "\e[0;35m", "\x0306" ],
+       'CYAN' => [ "\e[1;36m", "\x0311" ],
+       'DCYAN' => [ "\e[0;36m", "\x0310" ],
+       'WHITE' => [ "\e[1;37m", "\x0300" ],
+       'GREY' => [ "\e[0;37m", "\x0315" ],
+       'NORMAL' => [ "\e[0m", "\x03" ],
+       );
+       my @scheme = get_color_scheme($colors{'scheme'});
+       $colors{'c1'} = $color_palette{$scheme[0]}[$index];
+       $colors{'c2'} = $color_palette{$scheme[1]}[$index];
+       $colors{'cn'} = $color_palette{$scheme[2]}[$index];
+       # print Dumper \@scheme;
+       # print "$colors{'c1'}here$colors{'c2'} we are!$colors{'cn'}\n";
+       eval $end if $b_log;
+}
 
-               if [[ ${konvi[2]} == 'konversation' ]];then
-                       # note: we need to change this back to a single dot number, like 1.3, not 1.3.2
-                       konvi_qt4_client=$( konversation -v | grep -i 'konversation' | \
-                       gawk '{ print $2 }' | cut -d '.' -f 1,2 )
-                       if [[ $konvi_qt4_client > 1.1 ]]; then
-                               b_is_qt4='true'
-                       fi
-               fi
-       else
-               konvi_qt4="qt3"
-               b_is_qt4='false'
-       fi
-       log_function_data "b_is_qt4: $b_is_qt4"
-       echo $b_is_qt4
-       ## for testing this module
-       #qdbus org.kde.konversation /irc say $1 $2 "getpid_dir: $konvi_qt4  qt4_konvi: $konvi_qt4_ver   verNum: $konvi_qt4_ver_num  pid: $konvi_pid ppid: $PPID  konvi_home_dir: ${konvi[2]}"
+sub set_colors {
+       eval $start if $b_log;
+       # it's already been set with -c 0-43
+       if ( exists $colors{'c1'} ){
+               return 1;
+       }
+       # This let's user pick their color scheme. For IRC, only shows the color schemes, 
+       # no interactive. The override value only will be placed in user config files. 
+       # /etc/inxi.conf can also override
+       if (exists $colors{'selector'}){
+               my $ob_selector = SelectColors->new($colors{'selector'});
+               $ob_selector->select_schema();
+               return 1;
+       }
+       # set the default, then override as required
+       my $color_scheme = $colors{'default'};
+       # these are set in user configs
+       if (defined $colors{'global'}){
+               $color_scheme = $colors{'global'};
+       }
+       else {
+               if ( $b_irc ){
+                       if (defined $colors{'irc-virt-term'} && $b_display && $client{'console-irc'}){
+                               $color_scheme = $colors{'irc-virt-term'};
+                       }
+                       elsif (defined $colors{'irc-console'} && !$b_display){
+                               $color_scheme = $colors{'irc-console'};
+                       }
+                       elsif ( defined $colors{'irc-gui'}) {
+                               $color_scheme = $colors{'irc-gui'};
+                       }
+               }
+               else {
+                       if (defined $colors{'console'} && !$b_display){
+                               $color_scheme = $colors{'console'};
+                       }
+                       elsif (defined $colors{'virt-term'}){
+                               $color_scheme = $colors{'virt-term'};
+                       }
+               }
+       }
+       # force 0 for | or > output, all others prints to irc or screen
+       if (!$b_irc && ! -t STDOUT ){
+               $color_scheme = 0;
+       }
+       set_color_scheme($color_scheme);
+       eval $end if $b_log;
 }
 
-# This needs some cleanup and comments, not quite understanding what is happening, although generally output is known
-# Parse the null separated commandline under /proc/<pid passed in $1>/cmdline
-# args: $1 - $PPID
-get_cmdline()
+## SelectColors
 {
-       eval $LOGFS
-       local i=0 ppid=$1
-
-       if [[ ! -e /proc/$ppid/cmdline ]];then
-               echo 0
-               return
-       fi
-       ##print_screen_output "Marker"
-       ##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)"
-       unset A_CMDL
-       ## note: need to figure this one out, and ideally clean it up and make it readable
-       while read -d $'\0' L && [[ $i -lt 32 ]]
-       do
-               A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ##
-       done < /proc/$ppid/cmdline
-       ##print_screen_output "\$i='$i'"
-       if [[ $i -eq 0 ]];then
-               A_CMDL[0]=$(< /proc/$ppid/cmdline)
-               if [[ -n ${A_CMDL[0]} ]];then
-                       i=1
-               fi
-       fi
-       CMDL_MAX=$i
-       log_function_data "CMDL_MAX: $CMDL_MAX"
-       eval $LOGFE
+package SelectColors;
+
+# use warnings;
+# use strict;
+# use diagnostics;
+# use 5.008;
+
+my (@data,@rows,%configs,%status);
+my ($type,$w_fh);
+my $safe_color_count = 12; # null/normal + default color group
+my $count = 0;
+
+# args: 1 - type
+sub new {
+       my $class = shift;
+       ($type) = @_;
+       my $self = {};
+       return bless $self, $class;
+}
+sub select_schema {
+       eval $start if $b_log;
+       assign_selectors();
+       main::set_color_scheme(0);
+       set_status();
+       start_selector();
+       create_color_selections();
+       if (! $b_irc ){
+               main::check_config_file();
+               get_selection();
+       }
+       else {
+               print_irc_message();
+       }
+       eval $end if $b_log;
 }
 
-#### -------------------------------------------------------------------
-#### get data types
-#### -------------------------------------------------------------------
-## create array of sound cards installed on system, and if found, use asound data as well
-get_audio_data()
-{
-       eval $LOGFS
-       local i='' alsa_data='' audio_driver='' device_count='' a_temp=''
+sub set_status {
+       $status{'console'} = (defined $colors{'console'}) ? "Set: $colors{'console'}" : 'Not Set';
+       $status{'virt-term'} = (defined $colors{'virt-term'}) ? "Set: $colors{'virt-term'}" : 'Not Set';
+       $status{'irc-console'} = (defined $colors{'irc-console'}) ? "Set: $colors{'irc-console'}" : 'Not Set';
+       $status{'irc-gui'} = (defined $colors{'irc-gui'}) ? "Set: $colors{'irc-gui'}" : 'Not Set';
+       $status{'irc-virt-term'} = (defined $colors{'irc-virt-term'}) ? "Set: $colors{'irc-virt-term'}" : 'Not Set';
+       $status{'global'} = (defined $colors{'global'}) ? "Set: $colors{'global'}" : 'Not Set';
+}
 
-       IFS=$'\n'
-       # this first step handles the drivers for cases where the second step fails to find one
-       device_count=$( echo "$Lspci_v_Data" | grep -iEc '(multimedia audio controller|audio device)' )
-       if [[ $device_count -eq 1 ]] && [[ $B_ASOUND_DEVICE_FILE == 'true' ]];then
-               audio_driver=$( gawk -F ']: ' '
-               BEGIN {
-                       IGNORECASE=1
+sub assign_selectors {
+       if ($type == 94){
+               $configs{'variable'} = 'CONSOLE_COLOR_SCHEME';
+               $configs{'selection'} = 'console';
+       }
+       elsif ($type == 95){
+               $configs{'variable'} = 'VIRT_TERM_COLOR_SCHEME';
+               $configs{'selection'} = 'virt-term';
+       }
+       elsif ($type == 96){
+               $configs{'variable'} = 'IRC_COLOR_SCHEME';
+               $configs{'selection'} = 'irc-gui';
+       }
+       elsif ($type == 97){
+               $configs{'variable'} = 'IRC_X_TERM_COLOR_SCHEME';
+               $configs{'selection'} = 'irc-virt-term';
+       }
+       elsif ($type == 98){
+               $configs{'variable'} = 'IRC_CONS_COLOR_SCHEME';
+               $configs{'selection'} = 'irc-console';
+       }
+       elsif ($type == 99){
+               $configs{'variable'} = 'GLOBAL_COLOR_SCHEME';
+               $configs{'selection'} = 'global';
+       }
+}
+sub start_selector {
+       my $whoami = getpwuid($<) || "unknown???";
+       if ( ! $b_irc ){
+               @data = (
+               [ 0, '', '', "Welcome to $self_name! Please select the default 
+               $configs{'selection'} color scheme."],
+               );
+       }
+       @rows = (
+       [ 0, '', '', "Because there is no way to know your $configs{'selection'}
+       foreground/background colors, you can set your color preferences from 
+       color scheme option list below:"],
+       [ 0, '', '', "0 is no colors; 1 is neutral."],
+       [ 0, '', '', "After these, there are 4 sets:"],
+       [ 0, '', '', "1-dark^or^light^backgrounds; 2-light^backgrounds; 
+       3-dark^backgrounds; 4-miscellaneous"],
+       [ 0, '', '', ""],
+       );
+       push @data, @rows;
+       if ( ! $b_irc ){
+               @rows = (
+               [ 0, '', '', "Please note that this will set the $configs{'selection'} 
+               preferences only for user: $whoami"],
+               );
+               push @data, @rows;
+       }
+       @rows = (
+       [ 0, '', '', "$line1"],
+       );
+       push @data, @rows;
+       main::print_basic(@data); 
+       @data = ();
+}
+sub create_color_selections {
+       my $spacer = '^^'; # printer removes double spaces, but replaces ^ with ' '
+       $count = ( main::get_color_scheme('count') - 1 );
+       for my $i (0 .. $count){
+               if ($i > 9){
+                       $spacer = '^';
                }
-               # filtering out modems and usb devices like webcams, this might get a
-               # usb audio card as well, this will take some trial and error
-               $0 !~ /modem|usb|webcam/ {
-                       driver=gensub( /^(.+)( - )(.+)$/, "\\1", 1, $2 )
-                       gsub(/^ +| +$/,"",driver)
-                       if ( driver != "" ){
-                               print driver
-                       }
-               }' $FILE_ASOUND_DEVICE ) 
-               log_function_data 'cat' "$FILE_ASOUND_DEVICE"
-       fi
-
-       # this is to safeguard against line breaks from results > 1, which if inserted into following
-       # array will create a false array entry. This is a hack, not a permanent solution.
-       audio_driver=$( echo $audio_driver )
-       # now we'll build the main audio data, card name, driver, and port. If no driver is found,
-       # and if the first method above is not null, and one card is found, it will use that instead.
-       A_AUDIO_DATA=( $( echo "$Lspci_v_Data" | gawk -F ': ' -v audioDriver="$audio_driver" '
-       BEGIN {
-               IGNORECASE=1
-       }
-       /multimedia audio controller|audio device/ {
-               audioCard=gensub(/^[0-9a-f:\.]+ [^:]+: (.+)$/,"\\1","g",$0)
-               # The doublequotes are necessary because of the pipes in the variable.
-               gsub(/'"$BAN_LIST_NORMAL"'/, "", audioCard)
-               gsub(/'"$BAN_LIST_ARRAY"'/, " ", audioCard)
-               gsub(/^ +| +$/, "", audioCard)
-               gsub(/ [ \t]+/, " ", audioCard)
-               aPciBusId[audioCard] = gensub(/(^[0-9a-f:\.]+) [^:]+: .+$/,"\\1","g",$0)
-               cards[audioCard]++
-
-               # loop until you get to the end of the data block
-               while (getline && !/^$/) {
-                       gsub(/'"$BAN_LIST_ARRAY"'/, "", $0 )
-                       if (/driver in use/) {
-                               drivers[audioCard] = drivers[audioCard] gensub( /(.*): (.*)/ ,"\\2", "g" ,$0 ) ""
-                       }
-                       else if (/kernel modules:/) {
-                               modules[audioCard] = modules[audioCard] gensub( /(.*): (.*)/ ,"\\2" ,"g" ,$0 ) ""
-                       }
-                       else if (/^[[:space:]]*I\/O/) {
-                               portsTemp = gensub(/\t*I\/O ports at ([a-z0-9]+)(| \[.*\])/,"\\1","g",$0)
-                               ports[audioCard] = ports[audioCard] portsTemp " "
-                       }
-               }
-       }
-
-       END {
-               j=0
-               for (i in cards) {
-                       useDrivers=""
-                       useModules=""
-                       usePorts=""
-                       usePciBusId=""
-                        
-                       if (cards[i]>1) {
-                               a[j]=cards[i]"x "i
-                               if (drivers[i] != "") {
-                                       useDrivers=drivers[i]
-                               }
-                       }
-                       else {
-                               a[j]=i
-                               # little trick here to try to catch the driver if there is
-                               # only one card and it was null, from the first test of asound/cards
-                               if (drivers[i] != "") {
-                                       useDrivers=drivers[i]
-                               }
-                               else if ( audioDriver != "" ) {
-                                       useDrivers=audioDriver
-                               }
-                       }
-                       if (ports[i] != "") {
-                               usePorts = ports[i]
-                       }
-                       if (modules[i] != "" ) {
-                               useModules = modules[i]
-                       }
-                       if ( aPciBusId[i] != "" ) {
-                               usePciBusId = aPciBusId[i]
-                       }
-                       # create array primary item for master array
-                       sub( / $/, "", usePorts ) # clean off trailing whitespace
-                       print a[j] "," useDrivers "," usePorts "," useModules "," usePciBusId
-                       j++
+               if ($configs{'selection'} =~ /^global|irc-gui|irc-console|irc-virt-term$/ && $i > $safe_color_count ){
+                       last;
                }
-       }') )
-
-       # in case of failure of first check do this instead
-       if [[ ${#A_AUDIO_DATA[@]} -eq 0 ]] && [[ $B_ASOUND_DEVICE_FILE == 'true' ]];then
-               A_AUDIO_DATA=( $( gawk -F ']: ' '
-               BEGIN {
-                       IGNORECASE=1
+               main::set_color_scheme($i);
+               @rows = (
+               [0, '', '', "$i)$spacer$colors{'c1'}Card:$colors{'c2'}^nVidia^GT218 
+               $colors{'c1'}Display^Server$colors{'c2'}^x11^(X.Org^1.7.7)$colors{'cn'}"],
+               );
+               push @data, @rows;
+       }
+       main::print_basic(@data); 
+       @data = ();
+       main::set_color_scheme(0);
+}
+sub get_selection {
+       my $number = $count + 1;
+       @data = (
+       [0, '', '', ($number++) . ")^Remove all color settings. Restore $self_name default."],
+       [0, '', '', ($number++) . ")^Continue, no changes or config file setting."],
+       [0, '', '', ($number++) . ")^Exit, use another terminal, or set manually."],
+       [0, '', '', "$line1"],
+       [0, '', '', "Simply type the number for the color scheme that looks best to your 
+       eyes for your $configs{'selection'} settings and hit <ENTER>. NOTE: You can bring this 
+       option list up by starting $self_name with option: -c plus one of these numbers:"],
+       [0, '', '', "94^-^console,^not^in^desktop^-^$status{'console'}"],
+       [0, '', '', "95^-^terminal,^desktop^-^$status{'virt-term'}"],
+       [0, '', '', "96^-^irc,^gui,^desktop^-^$status{'irc-gui'}"],
+       [0, '', '', "97^-^irc,^desktop,^in^terminal^-^$status{'irc-virt-term'}"],
+       [0, '', '', "98^-^irc,^not^in^desktop^-^$status{'irc-console'}"],
+       [0, '', '', "99^-^global^-^$status{'global'}"],
+       [0, '', '',  ""],
+       [0, '', '', "Your selection(s) will be stored here: $user_config_file"],
+       [0, '', '', "Global overrides all individual color schemes. Individual 
+       schemes remove the global setting."],
+       [0, '', '', "$line1"],
+       );
+       main::print_basic(@data); 
+       @data = ();
+       my $response = <STDIN>;
+       chomp $response;
+       if ($response =~ /([^0-9]|^$)/ || ( $response =~ /^[0-9]+$/ && $response > ($count + 3) )){
+               @data = (
+               [0, '', '', "Error - Invalid Selection. You entered this: $response. Hit <ENTER> to continue."],
+               [0, '', '',  "$line1"],
+               );
+               main::print_basic(@data); 
+               my $response = <STDIN>;
+               start_selector();
+               create_color_selections();
+               get_selection();
+       }
+       else {
+               process_selection($response);
+       }
+}
+sub process_selection {
+       my $response = shift;
+       if ($response == ($count + 3) ){
+               @data = ([0, '', '', "Ok, exiting $self_name now. You can set the colors later."],);
+               main::print_basic(@data); 
+               exit 1;
+       }
+       elsif ($response == ($count + 2)){
+               @data = (
+               [0, '', '', "Ok, continuing $self_name unchanged."],
+               [0, '', '',  "$line1"],
+               );
+               main::print_basic(@data); 
+               if ( defined $colors{'console'} && !$b_display ){
+                       main::set_color_scheme($colors{'console'});
                }
-               $1 !~ /modem/ && $2 !~ /modem/ {
-                       card=gensub( /^(.+)( - )(.+)$/, "\\3", 1, $2 )
-                       driver=gensub( /^(.+)( - )(.+)$/, "\\1", 1, $2 )
-                       if ( card != "" ){
-                               print card","driver
-                       }
-               }' $FILE_ASOUND_DEVICE ) )
-       fi
-       IFS="$ORIGINAL_IFS"
-       get_audio_usb_data
-       # handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes..
-       if [[ ${#A_AUDIO_DATA[@]} -eq 0 ]];then
-               A_AUDIO_DATA[0]='Failed to Detect Sound Card!'
-       fi
-       a_temp=${A_AUDIO_DATA[@]}
-       log_function_data "A_AUDIO_DATA: $a_temp"
+               if ( defined $colors{'virt-term'} ){
+                       main::set_color_scheme($colors{'virt-term'});
+               }
+               else {
+                       main::set_color_scheme($colors{'default'});
+               }
+       }
+       elsif ($response == ($count + 1)){
+               @data = (
+               [0, '', '', "Removing all color settings from config file now..."],
+               [0, '', '',  "$line1"],
+               );
+               main::print_basic(@data); 
+               delete_all_config_colors();
+               main::set_color_scheme($colors{'default'});
+       }
+       else {
+               main::set_color_scheme($response);
+               @data = (
+               [0, '', '', "Updating config file for $configs{'selection'} color scheme now..."],
+               [0, '', '',  "$line1"],
+               );
+               main::print_basic(@data); 
+               if ($configs{'selection'} eq 'global'){
+                       delete_all_config_colors();
+               }
+               set_config_color_scheme($response);
+       }
+}
+sub delete_all_config_colors {
+       my @file_lines = main::reader( $user_config_file );
+       open( $w_fh, '>', $user_config_file ) or error_handler('open', $user_config_file, $!);
+       foreach ( @file_lines ) { 
+               if ( $_ !~ /^(CONSOLE_COLOR_SCHEME|GLOBAL_COLOR_SCHEME|IRC_COLOR_SCHEME|IRC_CONS_COLOR_SCHEME|IRC_X_TERM_COLOR_SCHEME|VIRT_TERM_COLOR_SCHEME)/){
+                       print {$w_fh} "$_"; 
+               }
+       } 
+       close $w_fh;
+}
+sub set_config_color_scheme {
+       my $value = shift;
+       my @file_lines = main::reader( $user_config_file );
+       my $b_found = 0;
+       open( $w_fh, '>', $user_config_file ) or error_handler('open', $user_config_file, $!);
+       foreach ( @file_lines ) { 
+               if ( $_ =~ /^$configs{'variable'}/ ){
+                       $_ = "$configs{'variable'}=$value";
+                       $b_found = 1;
+               }
+               print $w_fh "$_\n";
+       }
+       if (! $b_found ){
+               print $w_fh "$configs{'variable'}=$value\n";
+       }
+       close $w_fh;
+}
 
-       eval $LOGFE
+sub print_irc_message {
+       @data = (
+       [ 0, '', '', "$line1"],
+       [ 0, '', '', "After finding the scheme number you like, simply run this again
+       in a terminal to set the configuration data file for your irc client. You can 
+       set color schemes for the following: start inxi with -c plus:"],
+       [ 0, '', '', "94 (console,^not^in^desktop^-^$status{'console'})"],
+       [ 0, '', '', "95 (terminal, desktop^-^$status{'virt-term'})"],
+       [ 0, '', '', "96 (irc,^gui,^desktop^-^$status{'irc-gui'})"],
+       [ 0, '', '', "97 (irc,^desktop,^in terminal^-^$status{'irc-virt-term'})"],
+       [ 0, '', '', "98 (irc,^not^in^desktop^-^$status{'irc-console'})"],
+       [ 0, '', '', "99 (global^-^$status{'global'})"]
+       );
+       main::print_basic(@data); 
+       exit 1;
 }
-# alsa usb detection by damentz
 
-get_audio_usb_data()
-{
-       eval $LOGFS
-       local usb_proc_file='' array_count='' usb_data='' usb_id='' lsusb_data=''
-       local a_temp=''
-       
-       IFS=$'\n'
-       if type -p lsusb &>/dev/null;then
-               lsusb_data=$( lsusb 2>/dev/null )
-       fi
-       log_function_data 'raw' "usb_data:\n$lsusb_data"
-       if [[ -n $lsusb_data && -d /proc/asound/ ]];then
-               # for every sound card symlink in /proc/asound - display information about it
-               for usb_proc_file in /proc/asound/*
-               do
-                       # If the file is a symlink, and contains an important usb exclusive file: continue
-                       if [[ -L $usb_proc_file && -e $usb_proc_file/usbid  ]]; then
-                               # find the contents of usbid in lsusb and print everything after the 7th word on the
-                               # corresponding line. Finally, strip out commas as they will change the driver :)
-                               usb_id=$( cat $usb_proc_file/usbid )
-                               usb_data=$( grep "$usb_id" <<< "$lsusb_data" )
-                               if [[ -n $usb_data && -n $usb_id ]];then
-                                       usb_data=$( gawk '
-                                       BEGIN {
-                                               IGNORECASE=1
-                                               string=""
-                                               separator=""
-                                       }
-                                       {
-                                               gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 )
-                                               gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
-                                               gsub(/ [ \t]+/, " ", $0)
-                                               for ( i=7; i<= NF; i++ ) {
-                                                       string = string separator $i
-                                                       separator = " "
-                                               }
-                                               if ( $2 != "" ){
-                                                       sub(/:/,"", $4)
-                                                       print string ",USB Audio,,," $2 "-" $4 "," $6
-                                               }
-                                       }' <<< "$usb_data" )
-                               fi
-                               # this method is interesting, it shouldn't work but it does
-                               #A_AUDIO_DATA=( "${A_AUDIO_DATA[@]}" "$usb_data,USB Audio,," )
-                               # but until we learn why the above worked, I'm using this one, which is safer
-                               if [[ -n $usb_data ]];then
-                                       array_count=${#A_AUDIO_DATA[@]}
-                                       A_AUDIO_DATA[$array_count]="$usb_data"
-                               fi
-                       fi
-               done
-       fi
-       IFS="$ORIGINAL_IFS"
-       a_temp=${A_AUDIO_DATA[@]}
-       log_function_data "A_AUDIO_DATA: $a_temp"
-       
-       eval $LOGFE
 }
 
-get_audio_alsa_data()
-{
-       eval $LOGFS
-       local alsa_data='' a_temp=''
-
-       # now we'll get the alsa data if the file exists
-       if [[ $B_ASOUND_VERSION_FILE == 'true' ]];then
-               IFS=","
-               A_ALSA_DATA=( $( 
-               gawk '
-                       BEGIN {
-                               IGNORECASE=1
-                               alsa=""
-                               version=""
-                       }
-                       # some alsa strings have the build date in (...)
-                       # remove trailing . and remove possible second line if compiled by user
-                       $0 !~ /compile/ {
-                               gsub(/Driver | [(].*[)]|\.$/,"",$0 )
-                               gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0)
-                               gsub(/^ +| +$/, "", $0)
-                               gsub(/ [ \t]+/, " ", $0)
-                               sub(/Advanced Linux Sound Architecture/, "ALSA", $0)
-                               if ( $1 == "ALSA" ){
-                                       alsa=$1
-                               }
-                               version=$NF
-                               print alsa "," version
-                       }' $FILE_ASOUND_VERSION ) )
-               IFS="$ORIGINAL_IFS"
-               log_function_data 'cat' "$FILE_ASOUND_VERSION"
-       fi
-       a_temp=${A_ALSA_DATA[@]}
-       log_function_data "A_ALSA_DATA: $a_temp"
-       eval $LOGFE
-}
-
-get_battery_data()
-{
-       eval $LOGFS
-       local a_temp='' id_file='' count=0
-       local id_dir='/sys/class/power_supply/' 
-       local ids=$( ls $id_dir 2>/dev/null )  battery_file='' 
-       
-       # ids='BAT0 BAT1 BAT2'
-       if [[ -n $ids && $B_FORCE_DMIDECODE == 'false' ]];then
-               for idx in $ids
-               do
-                       battery_file=$id_dir$idx'/uevent'
-                       if [[ -r $battery_file ]];then
-                               #  echo $battery_file
-                               count=$(( $count + 1 ))
-                               IFS=$'\n'
-                               battery_data=$( 
-                               gawk -F '=' '
-                               BEGIN {
-                                       IGNORECASE=1
-                                       name=""
-                                       status=""
-                                       present=""
-                                       chemistry=""
-                                       cycles=""
-                                       voltage_min_design=""
-                                       voltage_now=""
-                                       power_now=""
-                                       charge_full_design=""
-                                       charge_full=""
-                                       charge_now=""
-                                       capacity=""
-                                       capacity_level=""
-                                       model=""
-                                       company=""
-                                       serial=""
-                                       of_orig=""
-                                       location=""
-                               }
-                               {
-                                       gsub(/'"$BAN_LIST_NORMAL"'|,|battery|unknown/, "", $2)
-                                       gsub(/^ +| +$/, "", $2)
-                               }
-                               $1 ~ /^POWER_SUPPLY_NAME$/ {
-                                       name=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_STATUS$/ {
-                                       status=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY$/ {
-                                       present=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_TECHNOLOGY$/ {
-                                       chemistry=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_CYCLE_COUNT$/ {
-                                       cycles=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_VOLTAGE_MIN_DESIGN$/ {
-                                       voltage_min_design = $NF / 1000000
-                                       voltage_min_design = sprintf( "%.1f", voltage_min_design )
-                               }
-                               $1 ~ /^POWER_SUPPLY_VOLTAGE_NOW$/ {
-                                       voltage_now = $NF / 1000000
-                                       voltage_now = sprintf( "%.1f", voltage_now )
-                               }
-                               $1 ~ /^POWER_SUPPLY_POWER_NOW$/ {
-                                       power_now=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_ENERGY_FULL_DESIGN$/ {
-                                       charge_full_design = $NF / 1000000
-                               }
-                               $1 ~ /^POWER_SUPPLY_ENERGY_FULL$/ {
-                                       charge_full = $NF / 1000000
-                               }
-                               $1 ~ /^POWER_SUPPLY_ENERGY_NOW$/ {
-                                       charge_now = $NF / 1000000
-                                       charge_now = sprintf( "%.1f", charge_now )
-                               }
-                               $1 ~ /^POWER_SUPPLY_CHARGE_FULL_DESIGN$/ {
-                                       charge_full_design = $NF / 100000
-                               }
-                               $1 ~ /^POWER_SUPPLY_CHARGE_FULL$/ {
-                                       charge_full = $NF / 100000
-                               }
-                               $1 ~ /^POWER_SUPPLY_CHARGE_NOW$/ {
-                                       charge_now = $NF / 100000
-                               }
-                               $1 ~ /^POWER_SUPPLY_CAPACITY$/ {
-                                       if ( $NF != "" ){
-                                               capacity=$NF "%"
-                                       }
-                               }
-                               $1 ~ /^POWER_SUPPLY_CAPACITY_LEVEL$/ {
-                                       capacity_level=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_MODEL_NAME$/ {
-                                       model=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_MANUFACTURER$/ {
-                                       company=$NF
-                               }
-                               $1 ~ /^POWER_SUPPLY_SERIAL_NUMBER$/ {
-                                       serial=$NF
-                               }
-                               END {
-                                       if (charge_now != "" && charge_full != "" ){
-                                               capacity = 100*charge_now/charge_full
-                                               capacity = sprintf( "%.1f%", capacity )
-                                       }
-                                       if (charge_full_design != "" && charge_full != "" ){
-                                               of_orig=100*charge_full/charge_full_design
-                                               of_orig = sprintf( "%.0f%", of_orig )
-                                       }
-                                       if (charge_now != "" ){
-                                               charge_now = sprintf( "%.1f", charge_now )
-                                       }
-                                       if (charge_full_design != "" ){
-                                               charge_full_design = sprintf( "%.1f", charge_full_design )
-                                       }
-                                       if ( charge_full != "" ){
-                                               charge_full = sprintf( "%.1f", charge_full )
-                                       }
-                                       entry = name "," status "," present "," chemistry "," cycles "," voltage_min_design "," voltage_now "," 
-                                       entry = entry power_now "," charge_full_design "," charge_full "," charge_now "," capacity "," 
-                                       entry = entry capacity_level "," of_orig "," model "," company "," serial "," location
-                                       print entry
-                               }' < $battery_file )
-                               # <<< "$data" )
-                               # < $battery_file ) 
-                               A_BATTERY_DATA[$count]=$battery_data
-                               IFS="$ORIGINAL_IFS"
-                       fi
-               done
-       elif [[ $B_FORCE_DMIDECODE == 'true'  ]] || [[ ! -d $id_dir && -z $ids ]];then
-               get_dmidecode_data
-               if [[ -n $DMIDECODE_DATA ]];then
-                       if [[ $DMIDECODE_DATA == 'dmidecode-error-'* ]];then
-                               A_BATTERY_DATA[0]=$DMIDECODE_DATA
-                       # please note: only dmidecode version 2.11 or newer supports consistently the -s flag
-                       else
-                               IFS=$'\n'
-                               # NOTE: this logic has a flaw, which is multiple batteries, which won't work without
-                               # gawk arrays, but sorry, too much of a pain given how little useful data from dmidecode
-                               A_BATTERY_DATA=( $( gawk -F ':' '
-                               BEGIN {
-                                       IGNORECASE=1
-                                       name=""
-                                       status=""
-                                       present=""
-                                       chemistry=""
-                                       cycles=""
-                                       voltage_min_design=""
-                                       voltage_now=""
-                                       power_now=""
-                                       charge_full_design=""
-                                       charge_full=""
-                                       charge_now=""
-                                       capacity=""
-                                       capacity_level=""
-                                       model=""
-                                       company=""
-                                       serial=""
-                                       of_orig=""
-                                       location=""
-                                       bItemFound="false"
-                               }
-                               {
-                                       gsub(/'"$BAN_LIST_NORMAL"'|,|battery|unknown/, "", $2)
-                                       gsub(/^ +| +$/, "", $1)
-                                       gsub(/^ +| +$/, "", $2)
-                               }
-                               /^Portable Battery/ {
-                                       while ( getline && !/^$/ ) {
-                                               if ( $1 ~ /^Location/ ) { location=$2 }
-                                               if ( $1 ~ /^Manufacturer/ ) { company=$2 }
-                                               if ( $1 ~ /^Serial/ ) { serial=$2 }
-                                               if ( $1 ~ /^Name/ ) { model=$2 }
-                                               if ( $1 ~ /^Design Capacity/ ) { 
-                                                       sub(/^[[:space:]]*mwh/, "", $2)
-                                                       charge_full_design = $NF / 1000
-                                                       charge_full_design = sprintf( "%.1f", charge_full_design )
-                                               }
-                                               if ( $1 ~ /^Design Voltage/ ) { 
-                                                       sub(/^[[:space:]]*mv/, "", $2)
-                                                       voltage_min_design = $NF / 1000
-                                                       voltage_min_design = sprintf( "%.1f", voltage_min_design )
-                                               }
-                                               if ( $1 ~ /^SBDS Chemistry/ ) { chemistry=$2 }
-                                       }
-                                       testString=company serial model charge_full_design voltage_min_design
-                                       if ( testString != ""  ) {
-                                               bItemFound="true"
-                                               exit # exit loop, we are not handling > 1 batteries
-                                       }
-                               }
-                               END {
-                                       if ( bItemFound == "true" ) {
-                                               name="BAT-1"
-                                               if (charge_now != "" && charge_full != "" ){
-                                                       capacity = 100*charge_now/charge_full
-                                                       capacity = sprintf( "%.1f%", capacity )
-                                               }
-                                               if (charge_full_design != "" && charge_full != "" ){
-                                                       of_orig=100*charge_full/charge_full_design
-                                                       of_orig = sprintf( "%.0f%", of_orig )
-                                               }
-                                               entry = name "," status "," present "," chemistry "," cycles "," voltage_min_design "," voltage_now "," 
-                                               entry = entry power_now "," charge_full_design "," charge_full "," charge_now "," capacity "," 
-                                               entry = entry capacity_level "," of_orig "," model "," company "," serial "," location
-                                               print entry
-                                       }
-                               }' <<< "$DMIDECODE_DATA" ) )
-                               IFS="$ORIGINAL_IFS"
-                       fi
-               fi
-       fi
-       # echo $array_string
-       
-       #echo ${#A_BATTERY_DATA[@]}
-       a_temp=${A_BATTERY_DATA[@]}
-       
-       # echo $a_temp
-       log_function_data "A_BATTERY_DATA: $a_temp"
-       eval $LOGFE
+#### -------------------------------------------------------------------
+#### CONFIGS
+#### -------------------------------------------------------------------
+
+sub check_config_file {
+       $user_config_file = "$user_config_dir/$self_name.conf";
+       if ( ! -f $user_config_file ){
+               open( my $fh, '>', $user_config_file ) or error_handler('create', $user_config_file, $!);
+       }
 }
 
-## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text
-## return value cpu core count string, this helps resolve the multi redundant lines of old style output
-get_cpu_core_count()
-{
-       eval $LOGFS
-       local cpu_physical_count='' cpu_core_count='' cpu_type='' cpu_alpha_count='' cores_per_cpu=''
-       local array_data=''
-       
-       if [[ $B_CPUINFO_FILE == 'true' ]]; then
-               # load the A_CPU_TYPE_PCNT_CCNT core data array
-               get_cpu_ht_multicore_smp_data
-               ## Because of the upcoming release of cpus with core counts over 6, a count of cores is given after Deca (10)
-               # count the number of processors given
-               cpu_physical_count=${A_CPU_TYPE_PCNT_CCNT[1]}
-               cpu_core_count=${A_CPU_TYPE_PCNT_CCNT[2]}
-               cpu_type=${A_CPU_TYPE_PCNT_CCNT[0]}
-
-               # match the numberic value to an alpha value
-               cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" )
-               
-               # create array, core count integer; core count string
-               # A_CPU_CORE_DATA=( "$cpu_core_count" "$cpu_alpha_count Core$cpu_type" )
-               array_data="$cpu_physical_count,$cpu_alpha_count,$cpu_type,$cpu_core_count"
-               IFS=','
-               A_CPU_CORE_DATA=( $array_data )
-               IFS="$ORIGINAL_IFS"
-       elif [[ -n $BSD_TYPE ]];then
-               local gawk_fs=': '
-       
-               if [[ $BSD_VERSION == 'openbsd' ]];then
-                       gawk_fs='='
-               fi
-               cpu_core_count=$( gawk -F "$gawk_fs" -v bsdVersion="$BSD_VERSION" '
-               # note: on openbsd can also be hw.ncpufound so exit after first
-               BEGIN {
-                       coreCount=""
-               }
-               $1 ~ /^hw.ncpu$/ {
-                       coreCount=$NF
-               }
-               /^machdep.cpu.core_count/ {
-                       coreCount=$NF
-               }
-               END {
-                       print coreCount
-               }' <<< "$Sysctl_a_Data" )
-               cores_per_cpu=$( gawk -F "$gawk_fs" '
-               /^machdep.cpu.cores_per_package/ {
-                       print $NF
-               }' <<< "$Sysctl_a_Data" )
-               
-               if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then
-                       cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" )
-                       if [[ $cpu_core_count -gt 1 ]];then
-                               cpu_type='-SMP-'
-                       else
-                               cpu_type='-UP-'
-                       fi
-               fi
-               if [[ -n $cores_per_cpu ]];then
-                       cpu_physical_count=$(( $cpu_core_count / $cores_per_cpu ))
-                       if [[ $cores_per_cpu -gt 1 ]];then
-                               cpu_type='-MCP-'
-                       fi
-               # do not guess here, only use phys count if it actually exists, otherwise handle in print_cpu..
-               # this 1 value should not be used for output, and is just to avoid math errors
-               else
-                       cpu_physical_count=1
-               fi
-               array_data="$cpu_physical_count,$cpu_alpha_count,$cpu_type,$cpu_core_count"
-               IFS=','
-               A_CPU_CORE_DATA=( $array_data )
-               IFS="$ORIGINAL_IFS"
-       fi
-       a_temp=${A_CPU_CORE_DATA[@]}
-       # echo $a_temp :: ${#A_CPU_CORE_DATA[@]}
-       log_function_data "A_CPU_CORE_DATA: $a_temp"
-       eval $LOGFE
-}
-
-# args: $1 - integer core count
-get_cpu_core_count_alpha()
-{
-       eval $LOGFS
-       local cpu_alpha_count=''
-       
-       case $1 in
-               1) cpu_alpha_count='Single';;
-               2) cpu_alpha_count='Dual';;
-               3) cpu_alpha_count='Triple';;
-               4) cpu_alpha_count='Quad';;
-               5) cpu_alpha_count='Penta';;
-               6) cpu_alpha_count='Hexa';;
-               7) cpu_alpha_count='Hepta';;
-               8) cpu_alpha_count='Octa';;
-               9) cpu_alpha_count='Ennea';;
-               10) cpu_alpha_count='Deca';;
-               *) cpu_alpha_count='Multi';;
-       esac
-       
-       echo $cpu_alpha_count
-       
-       eval $LOGFE
+sub get_configs {
+       my (@configs) = @_;
+       my ($key, $val,@config_files);
+       if (!@configs){
+               @config_files = (
+               qq(/etc/$self_name.conf), 
+               qq($user_config_dir/$self_name.conf)
+               );
+       }
+       else {
+               @config_files = (@configs);
+       }
+       # Config files should be passed in an array as a param to this function.
+       # Default intended use: global @CONFIGS;
+       foreach (@config_files) {
+               next unless open (my $fh, '<', "$_");
+               while (<$fh>) {
+                       chomp;
+                       s/#.*//;
+                       s/^\s+//;
+                       s/\s+$//;
+                       s/'|"//g;
+                       s/true/1/; # switch to 1/0 perl boolean
+                       s/false/0/; # switch to 1/0 perl boolean
+                       next unless length;
+                       ($key, $val) = split(/\s*=\s*/, $_, 2);
+                       get_config_item($key,$val);
+                       # print "f: $file key: $key val: $val\n";
+               }
+               close $fh;
+       }
 }
 
-## main cpu data collector
-get_cpu_data()
-{
-       eval $LOGFS
-       local i='' j='' cpu_array_nu='' a_cpu_working='' multi_cpu='' bits='' a_temp=''
-       local bsd_cpu_flags='' min_speed='' max_speed=''
+# args: 0: key; 1: value
+sub get_config_item {
+       my ($key,$val) = @_;
+       if ($key eq 'ALLOW_UPDATE' || $key eq 'B_ALLOW_UPDATE') {$b_update = int($val)}
+       elsif ($key eq 'ALLOW_WEATHER' || $key eq 'B_ALLOW_WEATHER') {$b_weather = int($val)}
+       elsif ($key eq 'CPU_SLEEP') {$cpu_sleep = $val if $val =~ /^[0-9\.]$/}
+       elsif ($key eq 'DL_TIMEOUT') {$dl_timeout = int($val)}
+       elsif ($key eq 'DOWNLOADER') {
+               if ($val =~ /^(curl|fetch|ftp|perl|wget)$/){
+                       # this dumps all the other data and resets %dl for only the
+                       # desired downloader.
+                       $val = set_perl_downloader($val);
+                       %dl = ('dl' => $val, $val => 1);
+               }}
+       elsif ($key eq 'FILTER_STRING') {$filter_string = $val}
+       elsif ($key eq 'LANGUAGE') {$language = $val if $val =~ /^(en)$/}
+       elsif ($key eq 'LIMIT') {$limit = int($val)}
+       elsif ($key eq 'OUTPUT_TYPE') {$output_type = $val if $val =~ /^json|screen|xml/}
+       elsif ($key eq 'PS_COUNT') {$ps_count = int($val) }
+       elsif ($key eq 'SENSORS_CPU_NO') {$sensors_cpu_nu = int($val)}
+       elsif ($key eq 'SHOW_HOST' || $key eq 'B_SHOW_HOST') { $show{'host'} = int($val)}
+       elsif ($key eq 'WEATHER_UNIT') { 
+               $val = lc($val) if $val;
+               if ($val && $val =~ /^(c|f|cf|fc|i|m|im|mi)$/){
+                       my %units = ('c'=>'m','f'=>'i','cf'=>'mi','fc'=>'im');
+                       $val = $units{$val} if defined $units{$val};
+                       $weather_unit = $val;
+               }
+       }
+       # layout
+       elsif ($key eq 'CONSOLE_COLOR_SCHEME') {$colors{'console'} = int($val)}
+       elsif ($key eq 'GLOBAL_COLOR_SCHEME') {$colors{'global'} = int($val)}
+       elsif ($key eq 'IRC_COLOR_SCHEME') {$colors{'irc-gui'} = int($val)}
+       elsif ($key eq 'IRC_CONS_COLOR_SCHEME') {$colors{'irc-console'} = int($val)}
+       elsif ($key eq 'IRC_X_TERM_COLOR_SCHEME') {$colors{'irc-virt-term'} = int($val)}
+       elsif ($key eq 'VIRT_TERM_COLOR_SCHEME') {$colors{'virt-term'} = int($val)}
+       # note: not using the old short SEP1/SEP2
+       elsif ($key eq 'SEP1_IRC') {$sep{'s1-irc'} = $val}
+       elsif ($key eq 'SEP1_CONSOLE') {$sep{'s1-console'} = $val}
+       elsif ($key eq 'SEP[23]_IRC') {$sep{'s2-irc'} = $val}
+       elsif ($key eq 'SEP[23]_CONSOLE') {$sep{'s2-console'} = $val}
+       # size
+       elsif ($key eq 'COLS_MAX_CONSOLE') {$size{'console'} = int($val)}
+       elsif ($key eq 'COLS_MAX_IRC') {$size{'irc'} = int($val)}
+       elsif ($key eq 'COLS_MAX_NO_DISPLAY') {$size{'no-display'} = int($val)}
+       elsif ($key eq 'INDENT') {$size{'indent'} = int($val)}
+       elsif ($key eq 'INDENT_MIN') {$size{'indent-min'} = int($val)}
+       #  print "mc: key: $key val: $val\n";
+       # print Dumper (keys %size) . "\n";
+}
+
+#### -------------------------------------------------------------------
+#### DEBUGGERS
+#### -------------------------------------------------------------------
+
+# called in the initial -@ 10 program args setting so we can get logging 
+# as soon as possible # will have max 3 files, inxi.log, inxi.1.log, 
+# inxi.2.log
+sub begin_logging {
+       return 1 if $fh_l; # if we want to start logging for testing before options
+       my $log_file_2="$user_data_dir/$self_name.1.log";
+       my $log_file_3="$user_data_dir/$self_name.2.log";
+       my $data = '';
+       $end='main::log_data("fe", (caller(1))[3], "");';
+       $start='main::log_data("fs", (caller(1))[3], \@_);';
+       #$t3 = tv_interval ($t0, [gettimeofday]);
+       $t3 = eval 'Time::HiRes::tv_interval (\@t0, [Time::HiRes::gettimeofday()]);' if $b_hires;
+       #print Dumper $@;
+       my $now = strftime "%Y-%m-%d %H:%M:%S", localtime;
+       return if $b_debug_timers;
+       # do the rotation if logfile exists
+       if ( -f $log_file ){
+               # copy if present second to third
+               if ( -f $log_file_2 ){
+                       rename $log_file_2, $log_file_3 or error_handler('rename', "$log_file_2 -> $log_file_3", "$!");
+               }
+               # then copy initial to second
+               rename $log_file, $log_file_2 or error_handler('rename', "$log_file -> $log_file_2", "$!");
+       }
+       # now create the logfile
+       # print "Opening log file for reading: $log_file\n";
+       open $fh_l, '>', $log_file or error_handler(4, $log_file, "$!");
+       # and echo the start data
+       $data = $line2;
+       $data .= "START $self_name LOGGING:\n";
+       $data .= "NOTE: HiRes timer not available.\n" if !$b_hires;
+       $data .= "$now\n";
+       $data .= "Elapsed since start: $t3\n";
+       $data .= "n: $self_name v: $self_version p: $self_patch d: $self_date\n";
+       $data .= '@paths:' . joiner(\@paths, '::', 'unset') . "\n";
+       $data .= $line2;
        
-       if [[ -f  /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq ]];then
-               max_speed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
-               if [[ -f  /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq ]];then
-                       min_speed=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq)
-               fi
-       fi
-
-       if [[ $B_CPUINFO_FILE == 'true' ]];then
-               # stop script for a bit to let cpu slow down before parsing cpu /proc file
-               sleep $CPU_SLEEP
-               IFS=$'\n'
-               A_CPU_DATA=( $( 
-               gawk -v cpuMin="$min_speed" -v cpuMax="$max_speed" -F': ' '
-               BEGIN {
-                       IGNORECASE=1
-                       # need to prime nr for arm cpus, which do not have processor number output in some cases
-                       nr = 0
-                       count = 0
-                       bArm = "false"
-                       # ARM cpus are erratic in /proc/cpuinfo this hack can sometimes resolve it. Linux only.
-                       sysSpeed="'$(get_cpu_speed_hack)'"
-                       speed = 0
-                       max = 0
-                       min = 0
-               }
-               # TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+
-               # TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
-               # Therefore PATCH to use [ \t]+ when TESTING!
-               /^processor[ \t]+:/ {
-                       gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF)
-                       gsub(/^ +| +$/, "", $NF)
-                       if ( $NF ~ "^[0-9]+$" ) {
-                               nr = $NF
-                       }
-                       else {
-                               if ( $NF ~ "^ARM" ) {
-                                       bArm = "true"
-                               }
-                               count += 1
-                               nr = count - 1
-                               cpu[nr, "model"] = $NF
-                       }
+       print $fh_l $data;
+}
+
+# NOTE: no logging available until get_parameters is run, since that's what 
+# sets logging # in order to trigger earlier logging manually set $b_log
+# to true in top variables.
+# args: $1 - type [fs|fe|cat|dump|raw] OR data to log
+# arg: $2 - 
+# arg: $one type (fs/fe/cat/dump/raw) or logged data; 
+# [$two is function name; [$three - function args]]
+sub log_data {
+       return if ! $b_log;
+       my ($one, $two, $three) = @_;
+       my ($args,$data,$timer) = ('','','');
+       my $spacer = '   ';
+       # print "1: $one 2: $two 3: $three\n";
+       if ($one eq 'fs') {
+               if (ref $three eq 'ARRAY'){
+                       my @temp = @$three;
+                       # print Data::Dumper::Dumper \@$three;
+                       $args = "\n${spacer}Args: " . joiner($three, '; ', 'unset');
                }
-               /^model name|^cpu\t+:/ {
-                       gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
-                       gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
-                       gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF)
-                       gsub(/^ +| +$/, "", $NF)
-                       gsub(/ [ \t]+/, " ", $NF)
-                       cpu[nr, "model"] = $NF
-                       if ( $NF ~ "^ARM" ) {
-                               bArm = "true"
-                       }
+               else {
+                       $args = "\n${spacer}Args: None";
                }
-               /^cpu MHz|^clock\t+:/ {
-                       if (speed == 0) {
-                               speed = $NF
-                       }
-                       else {
-                               if ($NF < speed) {
-                                       speed = $NF
-                               }
-                       }
-                       if ($NF > max) {
-                               max = $NF
+               # $t1 = [gettimeofday];
+               #$t3 = tv_interval ($t0, [gettimeofday]);
+               $t3 = eval 'Time::HiRes::tv_interval(\@t0, [Time::HiRes::gettimeofday()])' if $b_hires;
+               #print Dumper $@;
+               $data = "Start: Function: $two$args\n${spacer}Elapsed: $t3\n";
+               $spacer='';
+               $timer = $data if $b_debug_timers;
+       }
+       elsif ( $one eq 'fe') {
+               # print 'timer:', Time::HiRes::tv_interval(\@t0, [Time::HiRes::gettimeofday()]),"\n";
+               #$t3 = tv_interval ($t0, [gettimeofday]);
+               eval '$t3 = Time::HiRes::tv_interval(\@t0, [Time::HiRes::gettimeofday()])' if $b_hires;
+               #print Dumper $t3;
+               $data = "${spacer}Elapsed: $t3\nEnd: Function: $two\n";
+               $spacer='';
+               $timer = $data if $b_debug_timers;
+       }
+       elsif ( $one eq 'cat') {
+               if ( $b_log_full ){
+                       for my $file ($two){
+                               my $contents = do { local( @ARGV, $/ ) = $file; <> }; # or: qx(cat $file)
+                               $data = "$data${line3}Full file data: $file\n\n$contents\n$line3\n";
                        }
-                       gsub(/MHZ/,"",$NF) ## clears out for cell cpu
-                       gsub(/.00[0]+$/,".00",$NF) ## clears out excessive zeros
-                       cpu[nr, "speed"] = $NF
+                       $spacer='';
                }
-               /^cache size/ {
-                       cpu[nr, "cache"] = $NF
+       }
+       elsif ($one eq 'cmd'){
+               $data = "Command: $two\n";
+               $data .= qx($two);
+       }
+       elsif ($one eq 'data'){
+               $data = "$two\n";
+       }
+       elsif ( $one eq 'dump') {
+               $data = "$two:\n";
+               if (ref $three eq 'HASH'){
+                       $data .= Data::Dumper::Dumper \%$three;
                }
-               /^flags|^features/ {
-                       cpu[nr, "flags"] = $NF
-                       # not all ARM cpus show ARM in model name
-                       if ( $1 ~ /^features/ ) {
-                               bArm = "true"
-                       }
+               elsif (ref $three eq 'ARRAY'){
+                       # print Data::Dumper::Dumper \@$three;
+                       $data .= Data::Dumper::Dumper \@$three;
                }
-               /^bogomips/ {
-                       cpu[nr, "bogomips"] = $NF
+               else {
+                       $data .= Data::Dumper::Dumper $three;
                }
-               /vendor_id/ {
-                       gsub(/genuine|authentic/,"",$NF)
-                       cpu[nr, "vendor"] = tolower( $NF )
+               $data .= "\n";
+               # print $data;
+       }
+       elsif ( $one eq 'raw') {
+               if ( $b_log_full ){
+                       $data = "\n${line3}Raw System Data:\n\n$two\n$line3";
+                       $spacer='';
                }
-               END {
-                       #if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
-                       for ( i = 0; i <= nr; i++ ) {
-                               # note: assuming bogomips for arm at 1 x clock
-                               # http://en.wikipedia.org/wiki/BogoMips ARM could change so watch this
-                               # maybe add:  && bArm == "true" but I think most of the bogomips roughly equal cpu speed if not amd/intel
-                               # 2014-04-08: trying to use sysSpeed hack first, that is more accurate anyway.
-                               if ( ( cpu[i, "speed"] == "" && sysSpeed != "" ) || \
-                               ( cpu[i, "speed"] == "" && cpu[i, "bogomips"] != "" && cpu[i, "bogomips"] < 50  ) ) {
-                                       cpu[i, "speed"] = sysSpeed
-                               }
-                               else if ( cpu[i, "bogomips"] != "" && cpu[i, "speed"] == "" ) {
-                                       cpu[i, "speed"] = cpu[i, "bogomips"]
-                               }
-                               print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] ","  cpu[nr, "vendor"] "," bArm
-                       }
-                       if (cpuMin != "") {
-                               min=cpuMin/1000
-                       }
-                       if (cpuMax != "") {
-                               max=cpuMax/1000
-                       }
-                       # create last array index, to be used for min/max output
-                       sub(/\.[0-9]+$/,"",max)
-                       sub(/\.[0-9]+$/,"",speed)
-                       sub(/\.[0-9]+$/,"",min)
-                       if (speed == 0) {
-                               print "N/A," min "," max
-                       }
-                       else {
-                               print speed "," min "," max 
-                       }
-               } 
-               ' $FILE_CPUINFO ) )
-               
-               IFS="$ORIGINAL_IFS"
-               log_function_data 'cat' "$FILE_CPUINFO"
-       elif [[ -n $BSD_TYPE ]];then
-               get_cpu_data_bsd
-       fi
-       
-       a_temp=${A_CPU_DATA[@]}
-       log_function_data "A_CPU_DATA: $a_temp"
-#      echo ta: ${a_temp[@]}
-       eval $LOGFE
-#      echo getMainCpu: ${[@]}
-}
-# this triggers in one and only one case, ARM cpus that have fake bogomips data
-get_cpu_speed_hack()
-{
-       local speed=$( cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 2>/dev/null )
-       
-       if [[ -n $speed ]];then
-               speed=${speed%[0-9][0-9][0-9]} # trim off last 3 digits
-       fi
-       echo $speed
+       }
+       else {
+               $data = "$two\n";
+       }
+       if ($b_debug_timers){
+               print $timer if $timer;
+       }
+       #print "d: $data";
+       elsif ($data){
+               print $fh_l "$spacer$data";
+       }
 }
 
-get_cpu_data_bsd()
-{
-       eval $LOGFS
-
-       local bsd_cpu_flags=$( get_cpu_flags_bsd )
-       local gawk_fs=': ' cpu_max=''
-       
-       if [[ $BSD_VERSION == 'openbsd' ]];then
-               gawk_fs='='
-       fi
-       # avoid setting this for systems where you have no read/execute permissions
-       # might be cases where the dmesg boot file was readable but sysctl perms failed
-       if [[ -n $Sysctl_a_Data || -n $bsd_cpu_flags ]];then
-               if [[ -n $Dmesg_Boot_Data ]];then
-                       cpu_max=$( gawk -F ':' '
-                       BEGIN {
-                       IGNORECASE=1
-                       }
-                       # NOTE: freebsd may say: 2300-MHz, so check for dash as well
-                       $1 ~ /^(CPU|cpu0)$/ {
-                               if ( $NF ~ /[^0-9\.][0-9\.]+[\-[:space:]]*[MG]Hz/) {
-                                       max=gensub(/.*[^0-9\.]([0-9\.]+[\-[:space:]]*[MG]Hz).*/,"\\1",1,$NF)
-                                       if (max ~ /MHz/) {
-                                               sub(/[-[:space:]]*MHz/,"",max)
-                                       }
-                                       if (max ~ /GHz/) {
-                                               sub(/[-[:space:]]*GHz/,"",max)
-                                               max=max*1000
-                                       }
-                                       print max
-                                       exit
-                               }
-                       }' <<< "$Dmesg_Boot_Data" )
-               fi
-               IFS=$'\n'
-               A_CPU_DATA=( $( 
-               gawk -F "$gawk_fs" -v bsdVersion=$BSD_VERSION -v cpuFlags="$bsd_cpu_flags" -v cpuMax="$cpu_max" '
-               BEGIN {
-                       IGNORECASE=1
-                       cpuModel=""
-                       cpuClock=""
-                       cpuCache=""
-                       cpuBogomips=""
-                       cpuVendor=""
-                       bSwitchFs="false"
-                       min=0
-                       max=0
-               }
-             &n