#!/usr/bin/perl use strict; # Extracts today's data from iCal and prints it in simple text-only format. Recommended usage with # GeekTools (http://www.geektools.com) to display today's agenda on the desktop at all times. # # Required: iCal # # Note: This program needs lots of customization to work. iCal dumps its data into folders with long, arbitrary names, usually # in /Users/username/Library/Application Support/iCal/Sources/_____Long name____/corestorage.ics Before you start, you # need to check which data belongs to which calendar. Then, fill in the hash as appropriate. Two examples from my computer are given: my %calendars= ( "Work" => "/Users/berman/Library/Application Support/iCal/Sources/B86B64F3-5754-45CB-AC2A-713A83CFA441.calendar/corestorage.ics", "Other" => "/Users/berman/Library/Application Support/iCal/Sources/BB1861DB-FD3F-49C1-BBA1-212B9243D449.calendar/corestorage.ics" ); # # Author: David Berman # Last Modified: September 2006 chomp(my $now = `date "+%Y%m%d"`); #get and print today's date print `date "+%a %m/%d/%Y"`; foreach (keys %calendars){ #run print sub on each hash element open (raw_data, $calendars{$_}) or die "Error reading data for the $_ calendar: $!\n"; &searchAndPrint($_); } #Subroutine to search through the text and print out proper information sub searchAndPrint{ my($eventTime, $eventDescription); print "\n---$_[0]---\n"; #print title while(defined($_ = )){ #loop through data if(/DTSTART.*($now)/){ #search for today if(/T(\d\d\d\d)\d\d/){ #get time chomp($eventTime= $1); #convert to 12-hour clock if($eventTime == 0){$eventTime = "midnight";} elsif($eventTime > 0 && $eventTime < 0100){ $eventTime= $eventTime + 1200 . " am";} elsif($eventTime >=0100 && $eventTime <1200){ $eventTime = $eventTime . " am" ;} elsif($eventTime == 1200){ $eventTime = "noon" ;} elsif($eventTime > 1200 && $eventTime <1300){ $eventTime = $eventTime . " pm";} elsif($eventTime >=1300){ $eventTime = $eventTime - 1200 . " pm";} } until(/SUMMARY/){$_ = ;} #move down to "summary" if(/(SUMMARY):(.*)/){chop($eventDescription = $2);} #get event description print "$eventDescription @ $eventTime \n"; #print line } } }