Make an iCal event run an AppleScript

Having read the entry on creating a GTD Tickler file with Zak Greant’s AppleScript, Jennifer emails to ask how exactly you create an iCal event that will run the script every morning.

No doubt there are smarter ways to do this, but my method is outlined after the jump.


First, you need to make sure that the script you want to run is not saved as a stand-alone app. iCal can’t run scripts saved as apps. So in this case, when you load up Zak’s script into Script Editor, make sure that it is saved as a script (with the “scpt” extension).

alarm_initialeventOr Command-Click on the file on Zak’s site, select the “Download linked file” option. Start TextExit. Drag the saved file onto TextEdit and then select File > Save As… and save it somewhere memorable as GTDMail.scpt.

Now, create an event in iCal at the time that you would like to run the script. I do mine at 9 am. If I get to work before then, I let myself goof off and do some blogging.

You might be an early bird. Or more disciplined. Pick the time that suits.

Then you need to modify the event’s setting a bit in the drawer on the right.

In the repeat section, set it to run daily and to never end. Assign it to the right calendar.

alarm_selectScriptThen in the alarm section, select the “Run script” option. Select “Other…” and navigate to the location in which you have saved the script. My GTDMail.scpt is stored in my Home Directory in ~/Library/Scripts/Applications/Mail to keep things neat and tidy.

If you have it saved as an app you will see it there, but greyed out. Go back to the start and make sure that you have it saved as a script.

When you are done, the details for the whole event should look like this.

alarm_finishedevent

And in your iCal window you will see a relentless procession of repeated events, each one ready to serve up the contents of the Tickler file for the day:

alarm_endresult

The line also serves as a useful visual reminder that it is time to start work!

You’re done.

There are other ways to do this too. Every morning I get an email of BBC news headlines at 8 am. I could create a rule in Mail.app matching that email that would run the script. In fact, now that I come to the end of a long entry, that’s probably a better way, since Mail.app can run scripts saved as stand-alone apps.

Oh, well. At least you now have the general idea and will be able to set up the Mail rule easily by selecting “run AppleScript” from the “Actions to be performed” section.

Similar Posts:

Tags: , , , ,

3 Responses to “Make an iCal event run an AppleScript”

  1. Andreas Amann says:

    If you select “Open File” instead of “Run Script”, you can run any application (and thus also scripts saved as a application).

  2. Dan C says:

    Any idea of how to access properties of the event that is running the alarm? E.g., I want to access the name of the event I created in iCal in my AppleScript. Something like:

    set event_name to “… the ical event name …”

    Thanks!
    Dan

  3. Jeredb.com » Time to clean the inbox says:

    [...] Set it as an iCal alarm. [...]

Leave a Reply