#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG 7.5				#
#							#
# Licensed under GNU LESSER GENERAL PUBLIC LICENSE v3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

case $1 in
	1)
		load=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\1/" -e "s/ //g")
	;;
	
	10)
		load=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\2/" -e "s/ //g")
	;;
	
	15)
		load=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\3/" -e "s/ //g")
	;;

	*help | "")
		echo -e "$(bs-ng-parse-echo $white)Usage:\
		\n$(bs-ng-parse-echo $orange)showload$(bs-ng-parse-echo $white) | $(bs-ng-parse-echo $green)1 $(bs-ng-parse-echo $iceblue)[load average for 1 minute]\
		\n$(bs-ng-parse-echo $orange)showload$(bs-ng-parse-echo $white) | $(bs-ng-parse-echo $green)10 $(bs-ng-parse-echo $iceblue)[load average for 10 minutes]\
		\n$(bs-ng-parse-echo $orange)showload$(bs-ng-parse-echo $white) | $(bs-ng-parse-echo $green)15 $(bs-ng-parse-echo $iceblue)[load average for 15 minutes]"
	;;
esac

if [[ $1 != *help && $1 != "" ]]; then

tmp=$(echo $load*100 | bc)
load100=${tmp%.*}

if [[ $enabcol == true ]]; then

if [[ ${load100} -lt 35 ]]
then
  loadcolor=$(bs-ng-parse-echo $blue)
elif [[ ${load100} -ge 35 ]] && [[ ${load100} -lt 120 ]]
then
  loadcolor=$(bs-ng-parse-echo $iceblue)
elif [[ ${load100} -ge 120 ]] && [[ ${load100} -lt 200 ]]
then
  loadcolor=$(bs-ng-parse-echo $green)
elif [[ ${load100} -ge 200 ]] && [[ ${load100} -lt 300 ]]
then
  loadcolor=$(bs-ng-parse-echo $yellow)
else
  loadcolor=$(bs-ng-parse-echo $red)
fi

fi

echo -e $loadcolor$load

fi
