Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (54 sloc) 1.395 kb
#!/usr/bin/perl
=head1 NAME
bdcal - birthday calendars for pre-Tiger iCal
=cut
use strict;
use warnings;
use Mac::Glue qw(:glue);
my $ical = Mac::Glue->new("iCal");
my $ab = Mac::Glue->new("Address Book");
sub birthday_calendar {
my $cal_name = shift;
my $bdcal = $ical->obj(calendar => whose(title => equals => $cal_name));
if ($bdcal) {
$ical->delete($bdcal->obj('events'));
} else {
$bdcal = $ical->make(
new => 'calendar',
with_properties => { title => $cal_name }
);
}
$bdcal or die "could not acquire calendar!";
}
sub birthday_people {
my @people = $ab->obj('people')->get;
die "nobody found!" unless @people;
@people;
}
my $bdcal = birthday_calendar('Birthdays');
for my $person (birthday_people) {
my $birthday = $person->prop("birth date")->get;
next if $birthday eq 'msng';
my $recur =
"FREQ=YEARLY;INTERVAL=1;BYMONTH=" .
((localtime $birthday)[4]+1) .
";BYMONTHDAY=" .
(localtime $birthday)[3];
$ical->make(
new => 'event',
at => location(end => $bdcal),
with_properties => {
summary => ($person->prop("name")->get . "'s Birthday"),
'start date' => $birthday,
'allday event' => 1,
recurrence => $recur
}
);
}
print "Calendar updated!\n";
__END__
make new display alarm
at the end of
display alarms of
(item 1 of (myevent))
with properties {trigger interval:-15}
Jump to Line
Something went wrong with that request. Please try again.