icalBuddy: Getting Events and Tasks from the OS X Calendar Store via the Command Line

Posted on June 20, 2008
Filed under Mac, Programming

icalBuddy example pic I’m a big fan of the “do not repeat yourself” principle, which, especially in the context of software, basically means that you should only have one place to change anything. Any highly volatile data that will be viewed from more than one location (or in more than one way) should only have one location and/or interface for changing it. This way, whenever someone, somewhere, at some point in time happens to make changes to that data, all of the views that display it will reflect that change in true MVC fashion. The calendar store in OS X is a nice centralized database for calendar data that allows me to practice this principle when it comes to my calendars, and I’ve been very happy with it, given that I’ve also gotten automated synchronization with my cell phone to work.

I used dashboard widgets for a while for getting a quick overview of all of the events I have planned for the day plus any uncompleted tasks I might have, but soon noticed that I don’t actually go and see what’s up in the dashboard very often, which lead to me forgetting some things even though I had them set up as events or tasks in my calendars. The perfect place for displaying events for the day and any uncompleted tasks for me would thus be the desktop, which, even though it is most of the time obscured by a bunch of windows, I’ll occasionally glance at during the day. GeekTool is the solution for displaying any textual output from the shell on an OS X desktop, and I was using that already for some other things, so all that I needed was a CLI application or script that would get the events and tasks from the calendar store and output them in a nice readable way.

The only solution for this that I could find was made by some people over at macosxhints.com, who had come up with a Perl script for this purpose, but it didn’t seem very generic or reliable, so I started implementing my own version. I first tried to do it in Python, but soon ran into complexity issues with recurring events. Also, it wasn’t very fast. This was basically when I slapped myself in the head and realized that Apple has already provided a very nice API in Objective-C for getting calendar items from the database and working with them. With this, I started over and managed to come up with icalBuddy. Here’s an example of what its output might look like (this is a list of uncompleted tasks, separated by calendar:)

$ icalBuddy -sc uncompletedTasks
Blog stuff:
------------------------
* Write blog post about icalBuddy
    notes: add some nice pictures
    priority: high

Home:
------------------------
* Bask in your awesomeness
    priority: medium
* Try not to be so great all the time
    notes: People are getting jealous
    url: http://hasseg.org

Here’s what it looks like on my desktop via GeekTool:

I have a separate page up on this site for the application itself, including download links, examples of use and documentation (read: HTML version of the man page,) so head on over there if you’re interested.

Comments

24 Responses to “icalBuddy: Getting Events and Tasks from the OS X Calendar Store via the Command Line”

Show/hide comments & reply form: