Set alarms for subscribed iCal calendars

May 24, '04 09:36:00AM

Contributed by: MarkProgrammer

I was frustrated to find out that in iCal, I could not attach alarms to events from other people's calendars that I had subscribed to. However, I later discovered that this is actually possible. Even though you cannot change the alarm settings on events that you have imported from other people using iCal's user interface, you can change them through AppleScript! A script such as the following should work:

tell application "iCal" to make new sound alarm at end of ¬
(sound alarms of (event event_index of calendar cal_index)) ¬
with properties {trigger interval:-30, sound name: "Hero"}
event_index and cal_index are variables. You have to set them to the index of the calendar and event that you wish to access. So, for example, if you have calendars named "Work," "Personal," and "My Imported Calendar," set cal_index to 1 to get to Work, 3 for My Imported Calendar, etc. I believe the index numbers match with the order the calendars appear in the calendar selection column in iCal.

event_index is trickier, since events are organized internally in iCal using a method that is not easy for the user to see (I think it just assigns them an ID based on the order they were created). So this is sort of an "experienced scripter" hint; you'll have to build a short script to list the events in the calendar, find the event you want in the list, and set event_index to the cardinal position of the element. i.e., for events {foo, bar, Breakfast at Tiffany's}, bar has an event_index of 2).

Note that as of right now, iCal only allows you to access calendar events (and calendars themselves) by index, so this method is pretty clunky. But it does seem to work, although I haven't tested the effects of the calendar's publisher changing the calendar. Yet another example of a software feature "accidentally" added by the AppleScript interface!

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040519175456346