Retro GeekTool

Aprovechando que esta mañana me ha dado por ahí y he hecho una instalación limpia de Lion (hice update desde SL, vaya limpieza he hecho oiga xDD) me he instalado el GeekTool con una idea en mente, y después de buscar una buena fuente… voilà!

Space 1 (Izquierda)

Space 2 (Derecha)

Son 4 grupos de Geeklets, el de arriba-izquierda muestra la canción y grupo sonando en iTunes, arriba a la derecha está la información del tiempo en Barcelona y Tampere justo encima de la hora, y abajo derecha los eventos de los próximos 3 días extraídos de iCal.

Aquí dejo los snippets para cada Geeklet:

Info de iTunes

#!/bin/sh
 
if ps -x -o command \
 | grep '^/Applications/iTunes.app/' \
 | grep -q -v 'iTunesHelper';  then
osascript -e 'tell application "iTunes"
 
set trackname to name of current track
 
set artistname to artist of current track
 
set output to "" & trackname & "
" & artistname
 
end tell' | iconv -f utf-8 -t ucs-2-internal
 
fi

Información del Tiempo

echo "BCN\c"
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=SPXX0015&u=c" \
| grep -E '(Current Conditions:|C<BR)' \
| sed -e 's/Current Conditions://' -e 's/<br \/>//' \
-e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' \
-e 's/<description>//' -e 's/<\/description>//'

Hora

date +"%H:%M"

iCal (descargado de aquí, requiere MacRuby instalado)

#!/usr/local/bin/macruby
framework 'calendarstore'
 
# This required MacRuby to be installed.
# A package installer for 10.6+ is available at http://www.macruby.org/
 
# Period is the number of days (including today) to include in the list.
# The default is three days.
period = (3 * 3600 * 24)
range = Time.local(Time.now.year, Time.now.mon, Time.now.day).. \
(Time.local(Time.now.year, Time.now.mon, Time.now.day) + period)
 
predicate = CalCalendarStore.eventPredicateWithStartDate(\
NSDate.dateWithString(range.begin.to_s), endDate:NSDate\
.dateWithString(range.end.to_s), calendars:CalCalendarStore\
.defaultCalendarStore.calendars)
day_cache = nil
 
# All formatting done here is intended to be RIGHT JUSTIFIED.
# Inside the block everything except #timeIntervalSince1970 is normal ruby,
# so it should be pretty easy for many people to change around.
CalCalendarStore.defaultCalendarStore.eventsWithPredicate(predicate)\
.each do |event|
  started_at = Time.at(event.startDate.timeIntervalSince1970)
 
  print "\n" + started_at.strftime("%A %B %d").upcase + "\n" if \
  started_at.day != day_cache
 
  print "→" if started_at < Time.now
  print "⚠ " if (Time.now - started_at < (3600 * 5)) && (Time.now - \
  started_at > 0)
  print event.title
  print " (#{event.location})" if event.location
  print (event.isAllDay ? "        ∞" : started_at.strftime(" %R")) 
 
  print "\n"
  day_cache = started_at.day
end