Super Fuzzy Clock Geeklet

I recently discovered GeekTool for Mac and am an instant fan.  It allows you to layer scripts and images over your desktop to create a very custom view of basically anything you want.
Find out more about it here: http://projects.tynsoe.org/en/geektool/

Once you have it installed, head over to http://www.macosxtips.co.uk/geeklets/ to find some great little scripts to add.  Since there is very little documentation on the tool, studying these scripts is your best way to figure out how this thing works.
GeekTool isn't for the faint of heart so make sure your geek cred card hasn't expired before you start playing with it.

Here are a couple scripts that I put together this week that you might like.



Fuzzy Clock
There are a few fuzzy clocks in the geeklets list at macosxtips.com but I like my clocks to be super fuzzy and contain a bit more variety in the phrasing than what was already posted.  I also wanted the words to have some reflection on the desktop.


 
To make this script work you'll need to install imagemagick which is easily done through MacPorts (or Homebrew)
sudo port install imagemagick

Imagemagick isn't an easy beast either but with the help of Brett's post here, I was able to get the reflection to look like I wanted.

Once you have Imagemagick installed, drag a new shell module from the GeekTool app to the desktop and paste this script in the command field. Set it to refresh every 5 seconds or so.

#!/bin/bash
# ======= CONFIG ============================================
# set this to the location of ImageMagick's convert command
CONVERTER="/opt/local/bin/convert"
# set this to the location where your Image geeklet will look
OUTFILE="$HOME/reflected_time.png"
# set this to the font and font size you want to use for the text
FONT="noteworthy-light"
FONTSIZE=150
# ===========================================================

# don't mess with these
workdir=$TMPDIR
resultfile="$workdir/time.png"
HEADER=""
NUM_WORDS=(one two three four five six seven eight nine ten eleven twelve)
FUZZY_WORDS=("just after" "just after" "a few minutes past" "a few minutes past" "five after" "five after" "five after" "almost ten after" "almost ten after" "ten after" "ten after" "ten after" "almost a quarter after" "almost a quarter after" "a quarter past" "a quarter past" "a quarter past" "almost twenty past" "almost twenty past" "twenty past" "twenty past" "twenty past" "almost twenty-five after" "almost twenty-five after" "twenty-five after" "twenty-five after" "twenty-five after" "almost half past" "almost half past" "half past" "half past" "half past" "almost twenty-five to" "almost twenty-five to" "twenty-five to" "twenty-five to" "twenty-five to" "almost twenty to" "almost twenty to" "twenty to" "twenty to" "twenty to" "almost a quarter to" "almost a quarter to" "a quarter to" "a quarter to" "a quarter to" "almost ten to" "almost ten to" "ten to" "ten to" "ten to" "almost five to" "almost five to" "five to" "a few minutes before" "a few minutes before" "just about" "just about")

# create the fuzzy clock phrase
hrs=$(date '+%-l')
mins=$(date '+%-M')
if [ "$mins" -eq "0" ] 
then
    hr=${NUM_WORDS[hrs-1]}
    phrase="${HEADER} ${hr} o'clock"
elif [ "$mins" -lt "31" ] 
then
    hr=${NUM_WORDS[hrs-1]}
    min=${FUZZY_WORDS[mins-1]}
    phrase="${HEADER} ${min} ${hr}"
else
    hr=${NUM_WORDS[hrs]}
    min=${FUZZY_WORDS[mins-1]}
    phrase="${HEADER} ${min} ${hr}"
fi

# create the image of the time phrase
echo ${phrase}|$CONVERTER -background none -fill white -font ${FONT} -pointsize ${FONTSIZE} -trim label:@- $resultfile

# set the width and height variables
ww=`$CONVERTER $resultfile -format "%w" info:`
hh=`$CONVERTER $resultfile -format "%h" info:`
hhr=`$CONVERTER xc: -format "%[fx:$hh*40/50]" info:`

# clone the original image, flip it, composite a gradient and append it below the original
$CONVERTER $resultfile \
\( -size ${ww}x0 xc:none \) \
\( -clone 0 -flip +repage \) \
\( -clone 0 -alpha extract -flip +repage \
-size ${ww}x${hh} gradient: +level 0x50% \
-compose multiply -composite \) \
\( -clone 2 -clone 3 -alpha off -compose copy_opacity -composite \) \
-delete 2,3 -channel rgba -alpha on -background none -append $OUTFILE
exit 0
To change the font size or style just update the variables at the top of the script. You can also adjust the location where you want the resulting image to be saved. By default it saves it to your home directory.

Next drag an image module from GeekTool to the desktop and in the url field, select the 'reflected_time.png' file which should now be located in your home directory. Set the image to update every 5 seconds and you are good to go.
Position and resize the image to taste.

Feel free to leave constructive feedback below.
Cheers!
Scott