#!/usr/bin/env bash
# This script was auto generated using the code-cleanup package http://forumubuntusoftware.info/viewtopic.php?f=23&t=9480
# ==============================================================================
# title			:conky-builder
# description	:Builds a Conky skeleton based on hardware detected.
# author		:theemahn <theemahn@ultimateedition.info>
# date			:3/06/2018
# version		:1.30
# usage			:conky-builder --help
# manual		:man conky-builder
# notes			:See change-log below for further information.
# ==============================================================================
# Change-log:

# 1.0	initial public release

# 1.1	internal release

# 1.2	internal release

# 1.3	internal release

# 1.4	Added distribution detection, added resolution detection
#	to set fonts and sizes.

# 1.05	Added version compliance for deb based releases
#	Added better networking detection / wireless support.
#	Added memory output to compare against pae based kernels.
#	Added 800 X 600 support, how did I miss this resolution?
#	Added initial support for Ultimate Player (dynamically)
#	Added support for all network interface detection / Active.
#	Never have I seen this implementation.  I try to think outside of
#	the box please report issues.
#	Added support for Ultimate Edition 2.6.4 and 3.1 detection
#	Added dynamic Wireless support.
#	Added CPU Temp / Fan speeds also dynamic.

# 1.06	Added Radio tray to the mix
#	Initiated the anti-cron job mode of thinking, execi can be executed
#	w/o the need for a cron job.  Let's base this on the end users CPU.
#	Added no Internet means do not propagate - includes wireless.
#	The same across the board when I am done and hopefully will not
#	require a cron job.64bit

# 1.07	Initiated real-time information, across issues I have set forth.
#	Set CPU Temp to display info real-time based on end users processor. A
#	single core CPU will not be updated as fast as a quad for example
#	please see timeslices in my code.
#	Set fan speed accordingly as above.

# 1.08	Split the Conky builder for Ultimate Player info
#	May integrate the info as a function later.
#	Added progress bar for current playing track.
#	All info for Ultimate Player is now real-time.

# 1.09	First initial deb based release

# 1.10	Internal release for Ultimate Edition 3.01
#	Fixed improper spacing when closing Ultimate Player.

# 1.11	Fixed improper CPU detection on some Intel based processors.
#	Began writing weather location / detection via users IP address.
#	the above will be a fairly difficult procedure. Query to a API driven
#	Geo-positioning map to obtain location based on zip code, once obtained
#	a query to another API   driven site noaa.gov.  Will require no user
#	interaction.

# 1.12	Added support for 12.04 precise (Ultimate Edition 3.4 & 3.5) based releases.

# 1.13	Corrected colors to be only 1 color for now, easier reading on most wallpapers.
#	Will eventually write it to detect theme and set colors appropriately.

# 1.14	Added GPU and Main-board temp detection routines.
#	Added initial dual monitor detection / setup routine.
#	Added ppp0 network detection to the mix, thanks Seedo Eldho Paul
#	Added Hard-disk temperature detection, this was a rough one to sift
#	though and match with the drives.

# 1.15	Internal release to Ultimate Edition 3.5
#	Fixed Garbling of GPU / CPU Temp
#	Adjusted Colors to coincide with Ultimate Edition 3.5 Theme
#	Removed Lua usage. Thanks Mr. Breeg and Goliath for testing

# 1.16	Set colors in CLI so errors etc. Stand out.
#	Added additional distribution detection routines (debugging currently)
#	No sense in having to re-write conky builder every-time I build a new OS.
#	Display album art if Ultimate Player is Jamming.
#	Major code clean up, I am a slob ;)
#	Updated distribution logo
#	Mass updates to resolution detection routine. Simple once again becomes
#	complex thanks to addition of the artwork from Ultimate Player.

# 1.17	Adjusted output of information to comply with screen width.
#	Detection of USB drives - no output of temperature.
#	Detection of NAS drives - no output of temperature.
#	Added 1280 X 800 resolution; thanks, tanmay.01
#	Adjusted Temp detection routines let's not waste space.
#	Dual monitors now displayed @0 pixels from the top.
#	Took debugging into my own hands on temps.
#	Smartly built displaying of temp info into columns.
#	If no Swap. No Swap info reported in Conky. Save precious screen resources.
#	Reduced top processes to 3.
#	Adjusted diskio activity and network activity bars to coincide in length.

# 1.18	Added NFS based Network Attached Storage detection.

# 1.19	Ran code-clean and bashdepends on this script, dependencies adjusted.

# 1.20	Added Video card detection
#	Changed colors to coincide with colors of Ultimate Edition 3.4 series
#	Added Raid array detection

# 1.21	Point to point protocol issue gone?  Thanks again Seedo
# 	Implemented enhanced color / bar graphs.
#	Added 1366 X 768 resolution, thanks again Seedo

# 1.22	Check for install of hddtemp. Set as recommended in deb not required
#	Fixed errors spitting out when checking temp of USB / NAS drives.
#	Adjusted colors for Ultimate Edition 4.0
#	Adjusted mountpoints to strip username if applicable (12.10+ changed this)
#	Added check for SUID for hddtemp
#	Added Hard drive size detection & total filesystem capacity output info
#	Added Detecttion of root filesystem

# 1.23	Added support for 1920X2280 Dual monitor vertical orientation.
#	Ran code through bash script maker. Now has help and version system.

# 1.24	Added support for 1920X2400 Dual monitor vertical orientation.
#	Added better WiFi support (multiple adapters simotaneously supported).
#	Added full Ultimate Player detection.
# 	Ran software through code-cleanup package.
#	Added eyecandy functions.
#	Adjusted dependancies conky-all | conky-std, lm-sensors now recomended
#
# 1.25	Added initial support for 4K monitors.
#
# 1.26	Added support for Pithos (Pandora Client)
#		Added support for Clementine Media Player
#		Set recomends in control to recomend media | players
#		Cleaned up code.
#
# 1.27	Initiated NFS / Samba mounted hardware detection
#
# 1.28	Set compatability with KDE 5 (Ultimate Edition 5.7)
#
# 1.29  Added better detection of NAS (Network Attached Storage)
#
# 1.30  Added better detection of hard mounted USB devices.
#       Better detection of CPU Resonation on Multi-core CPUS.
#       Updated Media player detection.
#       Added GPU Temp detection / population
#       Added CPU Temp detection / population
#
# 1.31	Added support for Dual 4K monitors.
#		Added dependancy on glxinfo.
#
# 1.32	Adjusted Network Detection / reporting.
#		Cleaned up the CLI (Columize)
#
# =============== End Change-log ===================== #
# set -x <<- Enable for Debugging purposes

# Modify the below information to correlate with the software you are designing.
PROGNAME="conky-builder"
PROGRAMMER="theemahn"
BUILDDATE="01/19/2021"
VERSION="1.32"
WEBSITE="os-builder.com"
AUTHOR="TheeMahn"
EMAIL="<$AUTHOR@$WEBSITE>"
APPNAME="Conky Builder"

if [[ -f "ultimate-common" ]]; then
	source ultimate-common
elif [[ -f "/usr/share/ultimate_edition/ultimate-common" ]]; then
	source /usr/share/ultimate_edition/ultimate-common
else
	echo "No Ultimate Edition common source. Please install ultimate-edition-common."
fi

IPERF=$(type -p iperf3)
# Optional graphical notification, see if user has it installed.
NOTIFY=$(type -p notify-send)

# Optional Network Data
ETHTOOL=$(type -p ethtool)

# Monitor Data
shopt -u nullglob
declare -a MONITORS=();
declare -i NMONITORS;
WASIFS="$IFS"
IFS=$'\n'
MONITORS=$(xrandr -q | grep " connected" | cut -d "(" -f1 | cut -d "+" -f1)
NMONITORS=$(echo "${MONITORS[@]}" | wc -l)
MONITORS=($MONITORS)
IFS="$WASIFS"

DEBUG=$(echo "$*" | grep -i "debug")

NetInfo () {
	if ! [[ "${TERM}" == "dumb" ]]; then
		Center "Networking Information"
	else
		echo "Networking Information"
	fi
	Columnize -t 'DEVICE' 'UP/DOWN' 'SPEED' 'DUPLEX' 'TYPE'
	#Advance network detection to perfection scan all interfaces:
	shopt -s nullglob
	declare -a INTERFACES=()

	ACTIVE=""
	BYTE=0
	CURRENT="$PWD"
	if [[ -d "/sys/class/net/" ]]; then
		cd "/sys/class/net/" || exit 1;
		INTERFACES=(*/)
		for EACH in "${INTERFACES[@]}"
		do
			if [[ -f "/sys/class/net/${EACH%/}/operstate" ]]; then
				ACT=$(cat "/sys/class/net/${EACH%/}/operstate")
			else
				if [[ -d "/sys/class/net/${EACH%/}/" ]]; then
					Error "Error: /sys/class/net/${EACH%/}/ does not have a Operating State."
				else
					Error "Error: Device ${EACH%/} is not a networking device."
				fi
			fi
			if [[ "$ACT" == "up" ]]; then
					DEVICE="${EACH%/}"
					#ACTIVE="${EACH%/}"
					DUPLEX=$(ethtool "${DEVICE}" 2>/dev/null | grep -s -i "Duplex" | cut -d ":" -f2 | sed 's/ //g') 2>/dev/null
					ITYPE=$(ethtool "${DEVICE}" 2>/dev/null | grep -s "Port" | cut -d ":" -f2 | cut -d " " -f2) 2>/dev/null
					SPEED=$(ethtool "${DEVICE}" 2>/dev/null | grep -s -i "Speed" | cut -d ":" -f2 | sed 's/ //g') 2>/dev/null
					BYTES=$(ethtool --statistics "${DEVICE}" | grep -i "rxq0: rx_bytes:" | cut -d ":" -f3 | sed "s/ //g")
					if [[ "${BYTES}" == "" ]]; then
						if [[ -f "/sys/class/net/${DEVICE}/statistics/rx_bytes" ]]; then
							BYTES=$(cat "/sys/class/net/${DEVICE}/statistics/rx_bytes")
							SPEED=$(ethtool "${DEVICE}" 2>/dev/null | grep -s -i "Speed" | cut -d ":" -f2 | sed 's/ //g') 2>/dev/null
						fi
					fi
					if [[ "${BYTES}" -gt "${BYTE}" ]]; then
						ACTIVE="${EACH%/}"
						BYTE="${BYTES}"
					fi
				Columnize "${EACH%/}" "UP" "${SPEED}" "${DUPLEX}" "${ITYPE}"
				#Encapsulate "Interface: ${EACH%/} is $ACT"
			else
				#Encapsulate "Interface: ${EACH%/} is $ACT"
				if [[ "${EACH%/}" != "lo" ]]; then
					Columnize "${EACH%/}" "DOWN" "N/A" "N/A" "N/A"
				fi
			fi
		done
	else
		Error "No standard interface detected.  Point to Point Protocol?"
	fi
	if [[ "${ETHTOOL}" ]]; then
		SPEED=$(ethtool "${ACTIVE}" 2>/dev/null | grep -s -i "Speed" | cut -d ":" -f2 | sed 's/ //g') 2>/dev/null
	fi
	Encapsulate "Active Network: ${ACTIVE} speed detected at: ${SPEED}"
	IFACE=$(ifconfig "${ACTIVE}" | grep X.pa)
	Encapsulate "${ACTIVE}: ${IFACE}"
	FullBar
}

# Begin programming here.
#set Base, hi-light color & header please adjust colors in hex and font to your liking
#http://simple.wikipedia.org/wiki/List_of_colors
BASE='${color #ffffff}${font Liberation:style=normal:pixelsize='${FONTSIZE}'}' #Atomic Tangerine
HILIGHT='${color #ffff00}${font Liberation:style=normal:pixelsize='${FONTSIZE}'}' #Yellow
HEADER='${color #00ffff}${font Liberation:style=Bold:pixelsize='${FONTSIZE}'}' #Cyan
BAR='${color #ffd700}' #Gold

############### You Should not have to edit anything below #############

if [[ -f /usr/bin/ultimate-player ]]; then
	ULTIMATEPLAYER='/usr/bin/ultimate-player'
	UPSCRIPT='~.config/Ultimate-Player/UP.sh'
fi

# Dual monitors?
declare -i Dual

# Set hard-coded variables
ISHDDTEMP=$(which hddtemp)
ISHDDEXEC="NO"
SENSORS=$(which sensors)

Main() {
	if ! [[ "${TERM}" == "dumb" ]]; then
		VersionDump
	fi
	# Set default Operating System in case of failure
	OS='Ultimate Edition'

	# See if user has hddtemp installed, and more importantly has proper permissions
	# to execute it via user non-root (SUID).  If not inform the user how to fix it.
	# This stops: /dev/sda3: open: Permission denied errors.
	NetInfo "$@"
	# MANUALLY ADD RootFS to the mix, the only one guaranteed to be thier fs ;)
	MOUNTPOINT=$(df / | awk '{print $6}' | sed '1d')
	STRIPPED="RootFS"
	declare -a line=();
	line=$(df | grep -w "/" | sed "/rootfs/d" | cut -d" " -f1)
	#echo "ANALYSING ${EACH}"
	for EACH in "${line[@]}"
	do
	HDSIZE=$(df -H "${EACH}" | sed "1d" | awk '{print $2}')
	if [[ "${ISHDDTEMP}" ]]; then

		# TEST 2 conditions:
		# 1. NON-EXISTANT OUTPUT IE USB HDD / Burner
		# 2. Permissions to hddtemp SUID
		# Catch erronious output, eject it to null and skip smart checks.
		TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i 'Permission denied')
		if ! [[ $TSTVAR ]]; then
			TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i "t have a temperature sensor.")
		fi

		# hddtemp permissions are correct and a sensor exists on current drive.
		if ! [[ "$TSTVAR" ]]; then
			HDTEMP=$(hddtemp "$line" --unit=f --numeric 2>/dev/null)
			SMART=$(echo "${HDTEMP}" | grep -v "S.M.A.R.T. not available")
			SENSOR=$(echo "${HDTEMP}" | grep -v "have a temperature sensor")
		fi
	fi
	done
	#TSPACE=$(expr ${TSPACE} + ${HDSIZE})

	# display the information to end user in pretty columns
	if ! [[ "${TERM}" == "dumb" ]]; then
		Center "Storage Information"
	else
		echo "Storage Information"
	fi
	Columnize -t "DEVICE" "MOUNTPOINT" "HDTEMP" "HDSIZE"
	if [[ "${HDTEMP}" ]]; then
		Columnize "rootfs" "/" "${HDTEMP}°F" "${HDSIZE}"
	else
		Columnize "rootfs" "/" "N/A" "${HDSIZE}"
	fi

	awk '/dev\/sd/ {print $1}' /etc/mtab | sort | while read line
	do
		if [[ "$DEBUG" ]]; then
			echo "DEBUGGING: ${line}"
		fi
		MOUNTPOINT=$(df "${line}" | awk '{ s = ""; for (i = 6; i <= NF; i++) s = s $i " "; print s }' | sed '1d' | sed -e 's/[[:space:]]*$//')
		DISPMOUNTPOINT=$(echo "${MOUNTPOINT}" | sed "s/${USER}\///g" | sed "s/\/media\///g" | sed "s/media\///g" | sed "s/\/mnt\///g")
		STRIPPED=$(echo "${MOUNTPOINT}" | sed 's/\/media\///g')
		echo "${MOUNTPOINT}" >> /tmp/mpoint.txt
		if [ "$STRIPPED" = "/" ]; then
			STRIPPED="Root"
		fi

		HDDTMP=$(echo "$line" | sed 's/[0-9]*//g')
		#Future implementation?
		HDSIZE=$(df -H "$line" | sed "1d" | awk '{print $2}')

		#See if hddtemp is installed & SUID executable, if not don't do squat
		if [[ "${ISHDDTEMP}" ]]; then

			# TEST 2 conditions:
			# 1. NON-EXISTANT OUTPUT IE USB HDD / Burner
			# 2. Permissions to hddtemp SUID
			# Catch erronious output, eject it to null and skip smart checks.
			TSTVAR=$(hddtemp "$line" /dev/null 2>&1 |grep 'Permission denied')
			if ! [[ "$TSTVAR" ]]; then
				TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i "t have a temperature sensor.")
			fi

			# hddtemp permissions are correct and a sensor exists on current drive.
			if ! [[ "$TSTVAR" ]]; then
				HDTEMP=$(hddtemp "$line" --unit=f --numeric)
				SMART=$(echo "${HDTEMP}" | grep -v "S.M.A.R.T. not available")
				SENSOR=$(echo "${HDTEMP}" | grep -v "have a temperature sensor")
			fi
		fi
		#TSPACE=$(expr ${TSPACE} + ${HDSIZE})

		# If Temperature was detected populate Conky as well display info to user.
		if [[ "$SMART" != "" &&  "$SENSOR" != "" ]]; then
			Columnize "$line" "${DISPMOUNTPOINT}" "${HDTEMP}°F" "${HDSIZE}"
		else
			Columnize "$line" "${DISPMOUNTPOINT}" "N/A (USB?)" "${HDSIZE}"
		fi
	done;

	# Hard disks continued. HDA/B Etc.?
	awk '/dev\/hd/ {print $1}' /etc/mtab | sort | while read line
	do
		MOUNTPOINT=$(df "${line}" | awk '{print $6}' | sed '1d')
		DISPMOUNTPOINT=$(echo "${MOUNTPOINT}" | sed "s/$USER\///g" | sed "s/\/media\///g" | sed "s/media\///g" | sed "s/\/mnt\///g")
		STRIPPED=$(echo "${MOUNTPOINT}" | sed 's/\/media\///g')
		echo ${MOUNTPOINT} >> /tmp/mpoint.txt

		if [[ $STRIPPED == "/" ]]; then
			STRIPPED="Root"
		fi

		# Hard Drive / USB / Partition: Set temp readings if it applies as per drive."
		HDDTMP=$(echo "$line" | sed 's/[0-9]*//g')
		#See if hddtemp is installed & SUID executable, if not don't do squat
		if [[ "${ISHDDTEMP}" ]]; then

			# TEST 2 conditions:
			# 1. NON-EXISTANT OUTPUT IE USB HDD / Burner
			# 2. Permissions to hddtemp SUID
			# Catch erronious output, eject it to null and skip smart checks.
			TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i "Permission denied")
			if ! [[ "$TSTVAR" ]]; then
				TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i "t have a temperature sensor.")
			fi

			# hddtemp permissions are correct and a sensor exists on current drive.
			if ! [[ "$TSTVAR" ]]; then
				HDTEMP=$(hddtemp "$line" --unit=f --numeric)
				SMART=$(echo ${HDTEMP} | grep -v "S.M.A.R.T. not available")
				SENSOR=$(echo "${HDTEMP}" | grep -v "have a temperature sensor")
			fi
		fi

		HDSIZE=$(df -H "$line" | sed "1d" | awk '{print $2}')
		HDTEMP=$(hddtemp "$line" --unit=f --numeric)
		SMART=$(echo "${HDTEMP}" | grep -v "S.M.A.R.T. not available")
		SENSOR=$(echo "${HDTEMP}" | grep -v "have a temperature sensor")
		#TSPACE=$(expr ${TSPACE} + ${HDSIZE})

		# If Temperature was detected populate Conky as well display info to user.
		if [[ "$SMART" != "" &&  "$SENSOR" != "" ]]; then
			Columnize "$line" "${DISPMOUNTPOINT}" "${HDTEMP}°F" "${HDSIZE}"
		else
			Columnize "$line" "${DISPMOUNTPOINT}" "N/A" "${HDSIZE}"
		fi
	done;

	# Hard disks continued. RAID MD0 Etc.?
	awk '/dev\/md/ {print $1}' /etc/mtab | sort | while read line
	do
		MOUNTPOINT=$(df "$line" | awk '{print $6}' | sed "1d")
		DISPMOUNTPOINT=$(echo "${MOUNTPOINT}" | sed "s/$USER\///g" | sed "s/\/media\///g" | sed "s/media\///g" | sed "s/\/mnt\///g")
		STRIPPED=$(echo "${MOUNTPOINT}" | sed "s/\/media\///g")
		echo "${MOUNTPOINT}" >> /tmp/mpoint.txt

		if [[ "$STRIPPED" == "/" ]]; then
			STRIPPED="Root"
		fi

		# Hard Drive / USB / Partition: Set temp readings if it applies as per drive."
		HDDTMP=$(echo "$line" | sed "s/[0-9]*//g")
		HDSIZE=$(df -H "$line" | sed "1d" | awk '{print $2}')
		#TSPACE=$(expr ${TSPACE} + ${HDSIZE})

		# If Temperature was detected populate Conky as well display info to user.
		Columnize "$line" "${DISPMOUNTPOINT}" "N/A" ${HDSIZE}
	done;

	#NVME Drive(s)?
	awk '/dev\/nvme/ {print $1}' /etc/mtab | sort | while read line
	do
		if [[ "$DEBUG" ]]; then
			echo "DEBUGGING: ${line}"
		fi
		MOUNTPOINT=$(df "${line}" | awk '{ s = ""; for (i = 6; i <= NF; i++) s = s $i " "; print s }' | sed '1d' | sed -e 's/[[:space:]]*$//')
		DISPMOUNTPOINT=$(echo "${MOUNTPOINT}" | sed "s/${USER}\///g" | sed "s/\/media\///g" | sed "s/media\///g" | sed "s/\/mnt\///g")
		STRIPPED=$(echo "${MOUNTPOINT}" | sed 's/\/media\///g')
		echo "${MOUNTPOINT}" >> /tmp/mpoint.txt
		if [ "$STRIPPED" = "/" ]; then
			STRIPPED="Root"
		fi

		HDDTMP=$(echo "$line" | sed 's/[0-9]*//g')
		#Future implementation?
		HDSIZE=$(df -H "$line" | sed "1d" | awk '{print $2}')

		#See if hddtemp is installed & SUID executable, if not don't do squat
		if [[ "${ISHDDTEMP}" ]]; then

			# TEST 2 conditions:
			# 1. NON-EXISTANT OUTPUT IE USB HDD / Burner
			# 2. Permissions to hddtemp SUID
			# Catch erronious output, eject it to null and skip smart checks.
			TSTVAR=$(hddtemp "$line" /dev/null 2>&1 |grep 'Permission denied')
			if ! [[ "$TSTVAR" ]]; then
				TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i "t have a temperature sensor.")
				TSTVAR=$(hddtemp "$line" /dev/null 2>&1 | grep -i "determine")
			fi

			# hddtemp permissions are correct and a sensor exists on current drive.
			if ! [[ "$TSTVAR" ]]; then
				HDTEMP=$(hddtemp "$line" --unit=f --numeric)
				SMART=$(echo "${HDTEMP}" | grep -v "S.M.A.R.T. not available")
				SENSOR=$(echo "${HDTEMP}" | grep -v "have a temperature sensor")
			fi
		fi
		#TSPACE=$(expr ${TSPACE} + ${HDSIZE})

		# If Temperature was detected populate Conky as well display info to user.
		if [[ "$SMART" != "" &&  "$SENSOR" != "" ]]; then
			Columnize "$line" "${DISPMOUNTPOINT}" "${HDTEMP}°F" "${HDSIZE}"
		else
			Columnize "$line" "${DISPMOUNTPOINT}" "N/A (USB?)" "${HDSIZE}"
		fi
	done;

	# Step 2 NFS based NAS
	# or better yet write a function & eliminate a large chunk of code.
	df -h | awk '/:/ {print $1 "|" $2}' /etc/mtab | while read line
	do
        NET=$(echo "$line" | cut -d "|" -f1)
        NET="${NET##*/}"
        URL="NAS"
		MOUNTPOINT="$URL:$NET"
        MPOINT=$(echo "$line" | cut -d "|" -f2)
        FRIENDLY=$(echo "$MPOINT"  | sed "s/${USER}\///g" | sed "s/\/media\///g" | sed "s/media\///g" | sed "s/\/mnt\///g")
        if [[ "$FRIENDLY" ]]; then
            MOUNTPOINT="$MPOINT"
        fi
        SIZE=$(df -h "$MPOINT" | awk '{print $2}' | sed "1d")
        #echo "DEBUGGING: NET:$NET URL:$URL LINE:$line SIZE:$SIZE FRIENDLY:$FRIENDLY"
		STRIPPED=$(echo "${MOUNTPOINT}" | sed "s/\/media\///g")
		echo "${MOUNTPOINT}" >> /tmp/mpoint.txt
		fout=$(echo "${line}" | cut -d":" -f1)
		Columnize "${fout}" "${STRIPPED}" "N/A" "${SIZE}"
		HDDTMP=$(echo "${line}" | sed "s/[0-9]*//g")
	done;


	# Step 3 Burners
	awk '/dev\/sr/ {print $1}' /etc/mtab | sort | while read line
	do
		MOUNTPOINT=$(df "$line" | awk "{print $6}" | sed "1d")
		STRIPPED=$(echo "${MOUNTPOINT}" | sed "s/\/media\///g")
		if [ "$STRIPPED" = "/" ]; then
			STRIPPED="Root"
		fi
		Columnize "$line" "$STRIPPED" "N/A"
		HDDTMP=$(echo "$line" | sed "s/[0-9]*//g")
	done;

	# Step 4 - Why stop there snatch up NAS(s) drives.
	awk '/\/\// {print $2}' /etc/mtab | sort | while read line
	do
		MOUNTPOINT=$(df "$line" | awk '{print $8}' | sed '1d')
		STRIPPED=$(echo "${MOUNTPOINT}" | sed 's/\/media\///g')
		if [[ "$STRIPPED" == "/" ]]; then
			STRIPPED="Root"
		fi
		Columnize "$line" "$STRIPPED" "N/A"
		# No temp detection via network do not populate TEMP.
	done;
	TOTALS=$(df -H --total | grep 'total')
	Encapsulate "$TOTALS"
	# Network re-visit...
	if [[ -f "/tmp/mpoint.txt" ]]; then
		if [[ "$DEBUG" ]]; then
			cat /tmp/mpoint.txt
		fi
		rm -f "/tmp/mpoint.txt"
	fi
	if [[ "${UID}" == "0" ]]; then
		killall -9 conky
	fi
	exit 0 # make sure we exit graciously, we want to add to boot-up with && to allow
	# other processes to continue.  No sense in being a hog and slowing boot time.
}

# Help system - I have re-wrote this section to work with code-cleanup.
Help () {

	if [[ "$2" == "" ]]; then
		VersionDump
		PRAM="ALL"
	else
		if ! [[ $3 ]]; then
			VersionDump
			PRAM="$2"
		else
			PRAM="$2"
		fi
	fi

	case "$PRAM" in
		ALL)
		Center "Usage: $PROGNAME -<-COMMAND> [OPTION]"
		Encapsulate "Mandatory arguments to long options are identical for short options."
		Encapsulate "  possible commands..."
		Encapsulate ""
		Encapsulate "  -h	--help		this help message"
		Encapsulate "  -v	--version	dump version info and exit"
		Encapsulate ""
		Encapsulate "$PROGNAME --help [COMMAND] for further information.";
		FullBar;;
		ALL|v|version)
		Encapsulate ""
		Encapsulate "Usage version;"
		Encapsulate "$PROGNAME -v"
		Encapsulate "Displays $PROGNAME version number and exits.";
		FullBar;;
		ALL|h|help|\?)
		Encapsulate ""
		Encapsulate "Useage Help [COMMAND];"
		Encapsulate "$PROGNAME -h [COMMAND]"
		Encapsulate "Displays this message. For futher information $PROGNAME help [COMMAND]"
		Encapsulate "or refer to the manpages."
		Encapsulate ""
		Encapsulate "man $PROGNAME"
		Encapsulate ""
		Encapsulate "Example: $PROGNAME -h version"
		Encapsulate "Will display help about the command version"
		Fullbar;;
	esac
	exit 0
}

shopt -u nullglob
if ! [[ "${SUPPRESS}" ]]; then
	VersionDump "$@"
	Timer "Start" "${APPNAME}"
fi

case "$1" in
	-h|--help|-\?) Help "$@"; exit 0;;
	-v|--version) VersionDump "$@"; exit 0;;
	*) Main "$@"; exit 0;;
esac


# ==============================================================================
# This code was automatically cleaned up using code-cleanup
# title			:code-cleanup
# description		:Bash code cleanup script
# Author		:root
# date			:10/23/2013
# version		:1.7.2-1
# http://ultimateedition.info/
# ==============================================================================
