icalBuddy: Getting Events and Tasks from the OS X Calendar Store via the Command Line
Posted on June 20, 2008
Filed under Mac, Programming
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:)
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”
Either make sure that the location of the icalBuddy binary is added to your PATH environment variable in your shell config file (~/.bashrc or ~/.bash_profile) or just use an absolute path in the geektool entry (/usr/local/bin/icalBuddy or wherever it is that you have it)
G
Just one thing – I can not find how to get UTF 8 encoding to work?
Check out the FAQ for info on how to enable UTF-8 in Apple’s Terminal.app, iTerm and GeekTool.
GeekTool with UTF-8 support worked just fine!
Thanks again – now I have also localized latvian version!
Thanks for the great work!
You just need to use a program that supports ANSI escape sequences to call icalBuddy and display its output. Apple’s Terminal.app and iTerm both support them, but GeekTool doesn’t.
I’ve actually added support for ANSI escape sequences (as well as a couple of other things) into GeekTool but I’ve had some trouble contacting the original author about licensing issues (I’m not comfortable releasing my version of it to the general public if no open-source license is specified for the original code.) I hope I get this sorted out with him ASAP, since I’d love to release my changes to it.
http://hasseg.org/blog/?p=350
However, I’m having trouble with my output. For some reason, each of my event titles is preceded by ΓΆΒΆ, or â¢
How can i correct this? Any idea where this is coming from?
Thanks.
Anyone seen this? Any idea what’s up?
I’ve heard from a couple of users about the problem you describe. I sent debug binaries to one user who then forwarded the log outputs to me and I traced the hangup to the call that goes out to the OS CalendarStore framework to retrieve the calendar items. The predicate object used in the call seemed fine as well so it looked like there might be a bug in the Leopard CalendarStore, especially since I haven’t heard of anyone having this issue on Snow Leopard.
I can’t really do any proper testing related to this since I don’t have Leopard installed at home anymore; our Mac Mini (which I had running Leopard for testing purposes) started having display issues a while back so I had to upgrade it to Snow Leopard.
If you could let me know at some point if upgrading to 10.6 seems to fix the issue, that would be great. I would then feel more comfortable adding an entry into the FAQ about this.
I released a new version of icalBuddy that might fix the hangups you’ve been encountering — you should give it a try. You can update it by running “icalBuddy -u” in the terminal or by downloading it from the website and installing it manually.
Any idea how to get icalBuddy to display “Delegate” calendars (i.e. calendar accounts like gmail, etc. setup in iCal proper)?