A Better Way to fix OSX Calendar & Google Hangouts

A Better Way to fix OSX Calendar & Google Hangouts

Tags
Tips & Tricks
Computer Science
Software Development
Published
December 23, 2013
Author
Randall Hand
URL
So, ever since
Connecting Google Hangouts to OSX Calendar
, when I was working on OSX Calendar and Google Hangout, I’ve been annoyed by the constant need to drag appointments onto the little automator robot each time.  I grew to loathe that little robot, sucking precious seconds of my time prior to each meeting.. The, taking almost 2 minutes every time to launch automator, process my calendar, and then update it.  The end result was that I went back to Google Calendar.
 
So, I’ve spent some time over the last few weekends and came up with a _much_ better options.  The result is available on github as CalendarHangout.  Setup and run the script, and see every calendar event in Calendar suddenly have a nice little URL link at the bottom that you can click on to launch hangout.
 
Simply download (or clone) that, and edit the script with the name of your calendar in Google (typically your email address).  Then run it once by hand, and go through the steps to authenticate it (GData3 API requires OAuth authentication).  Then, you can toss it into a cronjob or just run it on occasion to fix everything 2-weeks out!
 
So what’s it going?  It gets a list of all appointments on the 2-week horizon from Google, then uses AppleScript to update each one with the Hangout Link.  Due to the obnoxious nature of both companies involved (Google and Apple), this is far more frustrating than it needs to be:
 
* Google doesn’t support the RFC standard “URL” field, which would make this trivial.
* Apple doesn’t offer any robust way to get occurrences of repeating events. 
* Apple Calendar tends to take a long time & lots of CPU cycles to make these changes, and applescript seems to be the only way to talk to them.  
 
So, I use Google Calendar’s API to get events that are happening in the next two weeks, where AppleScript would fail because of their appalling recurrence support.  Then, I use AppleScript to update the events on your local calendar (connecting them via UID), since Google doesn’t support the decades-old “URL” field.
 
And it all works!  It’s slow, taking approximately 10 minutes to run on my machine (and maxing out all CPU’s as it does).  I know, that’s a stupid computational load but seems to be due to a known bug in OSX Calendar (look for talk of tccd and applescript calendar slow).  
 
So try it out, if you find any glitches or make any improvements post in the comments! (or even better, submit a pull request via GitHub!)