Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'GeekTool - Ideas of using it' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
GeekTool - Ideas of using it
Authored by: mrchaotica on Jul 09, '04 01:42:23AM

I've made myself a little shell script to show me useful status information (date, quote-of-the-day, battery charge, uptime, CPU temperature, disk usage, and now external IP (thanks Gfx!))

Note that battery status and CPU temp use external programs, and I'm not sure if they're redistributable - I'm pretty sure I grabbed them out of some Konfabulator widgets or something, if you want to try to find them. Also, QOTD just reads a file that I created by calling fortune in a cron job, so set that up if you want to use it.

Anyway, here's the script:

#!/bin/sh

# Jack's Ultimate Status Script
# Prints battery status, uptime, CPU temperature,
# time and date, external IP, disk usage, and QOTD

# input escape characters in emacs with ctrl-q <esc>

date
echo Quote of the Day:
echo `cat ~/QOTD` 
#/usr/local/bin/battery 
BATT=$(/usr/local/bin/battery compact | awk '{print $4 " " $9}')
BATT1=$(echo $BATT | awk '{print $1}')
BATT2=$(echo $BATT | awk '{print $2}')
BATT2INT=` echo $BATT2 | sed s/\..$//g `
if [ $BATT1 -eq 00000111 ]; then
	echo Battery charge: ${BATT2}%  \[charging\]
else
    if (( $BATT2INT < 20 )); then
	echo Battery charge: ${BATT2}%
    elif (( 20 < $BATT2INT < 50 )); then
	echo Battery charge: ${BATT2}%
    else
	echo Battery charge: ${BATT2}%
    fi
fi


#PRINT UPTIME
UPTIME=$(uptime)
UPDAY=$(echo $UPTIME | awk '{ print $3 }')
UPHOUR=$(echo $UPTIME | awk '{ print $5 }' | sed s/:.*//g)
UPMIN=$(echo $UPTIME | awk '{ print $5 }' | sed s/.*://g | sed s/,//g)
echo Uptime: $UPDAY days, $UPHOUR hours, $UPMIN minutes

# PRINT CPU TEMPERATURE INFO
TEMP=`/usr/local/bin/tempSensor -f`
TEMPINT=` echo $TEMP | sed s/\..$//g `
if (( $TEMPINT > 140 )) ; then
    echo CPU Temp: $TEMP degrees Fahrenheit
elif (( 130 < $TEMPINT < 140 )) ; then
    echo CPU Temp: $TEMP degrees Fahrenheit
else
    echo CPU Temp: $TEMP degrees Fahrenheit
fi

#PRINT DISK USAGE INFO
df -h | grep disk0s9 | awk '{print "Macintosh HD:", $2, "total,", $3, 
"used,", $4, "remaining"}'

#PRINT EXTERNAL IP ADDRESS
echo External IP: `curl -s http://checkip.dyndns.org/ | sed 's/[a-zA-Z<>/ :]//g'`

exit 0

By the way, the little box characters are escape characters; they denote ANSI color escape codes, which don't work in GeekTool. The easiest thing would just be to delete them.



[ Reply to This | # ]
GeekTool - Ideas of using it
Authored by: gent99 on Jul 09, '04 08:01:21AM

i would like to use this script, but i don't have /usr/local/bin/battery and /usr/local/bin/tempSensor here

Where can i get those commands?



[ Reply to This | # ]