The Perfect Storm of Calendar Synchronization: iCal, Google Calendar and Cell Phone

There was a time when I could keep my entire schedule in my head. Years of university test times and due dates were dutifully tracked by my brain. In the intervening years, however, I seem to have killed most of my long and short term memory with booze — or maybe I’m just a whole lot busier.

In any case, I’ve been facing an increased sense of panic every time I try to book an appointment. What if I have a conflict? Krista keeps her entire life in the pages of a daily calendar, so I’ve attempted to follow suit, digital style.

This isn’t the first time I’ve tried, but every previous attempt failed for one reason or another:

  • Google Calendar: I love having my schedule available from pretty much any machine with an internet connection, but launching it seems horribly slow and the whole experience is oddly divorced from everything else on my Mac. I could write a whole other post (and maybe I will) about my migration from Windows native apps to Web Applications, and back to native Mac apps. I think it says a lot about how good OS X’s integrated tools are, though, that I’ve taken that path.
  • iCal: really, a beautiful calendar, but I missed the “everywhere-ness” of Google Calendar. I can do a one-way sync from Google to iCal using iCal’s Subscriptions, but anything I add to my local calendar won’t get reflected back. This is critical, as I’d like to be able to check the calendar from any other machine, including my cell.
  • Sony Ericsson k790’s built-in Calendar application: a surprisingly full-featured little calendar tool. For my process to work, I need to be able to quickly add events on the go. iSync takes care of synchronizing iCal and the k790, but I’m too forgetful (and lazy) to sync it myself whenever changes are made.
To achieve the Omega Point of calendar synchronization, I needed a few extra tools.
  1. Spanning Sync – the only part of the system that will cost extra money, Spanning Sync works perfectly for two-way synchronization between iCal and Google Calendar.
  2. Proximity – a nice little free application that monitors the presence of a bluetooth enabled device (in most cases, a phone) and runs AppleScripts based on it’s appearance and disappearance.
Most of the heavy lifting was already done by Jesse Hollington at The Technocrat. A lot of what I’m presenting here regarding Proximity is a modification of his work for my own preferences. His posting gives a very thorough examination of Proximity and some of its other uses, and is well worth a read.

For my purposes, I was mostly interested in having iSync silently keep my phone updated, as well as keeping Address Book attached to the device so I could respond to SMS messages directly on the Mac.

After installing Proximity, I created an Entering Proximity script to manage iSync. I was primarily concerned with keeping the iSync process invisible, which was achieved by adding some application exit status detection to Jesse’s script. Here’s what I came up with:


tell application "Address Book"
if not unsaved then
try
quit
delay 1
end try
end if
end tell
-- Reconnect to the Address Book
do shell script "defaults write com.apple.AddressBook
 ABCheckForPhoneNextTime -boolean true"
try
tell application "Address Book"
launch
end tell

tell application "System Events" set the visible of process "Address Book" to no end tell

end try

-- Synchronize the Device tell application "iSync" launch tell application "System Events" to set visible of process "iSync" to false if last sync is less than ((current date) - 900) then synchronize

repeat while (syncing is true) delay 5 end repeat set syncStatus to sync status

if syncStatus = 2 then -- Success quit else if syncStatus = 3 then set syncStatus to "completed with warnings" else if syncStatus = 4 then set syncStatus to "completed with errors" else if syncStatus = 5 then set syncStatus to "last sync cancelled" else if syncStatus = 6 then set syncStatus to "last sync failed to complete" else if syncStatus = 7 then set syncStatus to "never synced" end if display dialog "syncStatus: " & syncStatus syncStatus end if end if end tell

I didn’t bother with an Exiting Proximity script, although there are plenty of entertaining tasks that you could automate in this fashion. I also lowered to update frequency on Proximity to 60 seconds.

The beauty of this system is I can now

  • add an event using iCal, Google Calendar, or directly on my phone and have it automagically appear across all devices.
  • receive reminders, no matter my location.
  • share my calendars with friends through Google Calendar.
Let’s hope my semi-functional brain can now recall important events occurring more than 2 days into the future. My relationship probably depends on it.