Script for Quick Add to Google Calendar

Sharing and discussing custom actions for LaunchBar
abdiel2000
Posts: 9
Joined: Mon Dec 31, 2007 12:27 am

Script for Quick Add to Google Calendar

Postby abdiel2000 » Mon Jul 21, 2008 11:44 am

EDIT (7/29): Updated the script to use the "quoted form" of the text you enter to allow for double-quotes and ampersands, etc. Also changed it so that it works with Safari instead so it's more universal....

I'm not at all a coder and someone may have already posted a solution for this, but it works really well for me so I thought I'd share it with others here.

This script will allow you to directly create events in your Google Calendar using Launchbar and Google's natural language Quick Add feature. Just activate Launchbar, type in the script name, hit the space bar, type in your event in natural language (e.g. Dinner with Bob at 6pm on Thursday) and your Google Calendar will open in your browser with the event nicely added.

Just to be clear, I am standing on the shoulders of giants here. The original sources and inspiration for this method can be found here

http://hackaddict.blogspot.com/2007/10/ ... k-add.html

and here

http://inik.net/launchbar_terminal_command#attachments

A hearty thank you to both authors/coders! There is absolutely no way I could have done this without you!

OK, now for the how-to:

Making this script work requires some initial set-up that sounds scary for us non-coders, but it's actually very easy and didn't take me more than 10 minutes.

As I said, the actual heavy lifting to interface with your Google Calendar is done in Terminal, so you need to install a few Python scripts.

Here's the step-by-step

1) You need to install the GData Python module and the dateutil Python module. You can find links for both here

http://code.google.com/p/gcalcli/

(As for the other requirements mentioned on this page, the version of Python included with OS X 10.5.4 works just fine and includes the ElementTree Python module, so no need to install those if you are up to date. Otherwise, if you need them, links for those updates can also be found on that page.)

Full instructions for installing the GData Python module can be found here:

http://code.google.com/support/bin/answ ... swer=75582

But it's actually amazingly easy if you're using an admin account. Download the module with the most recent revision number, open the zip file which will reveal a folder, select that folder in Finder, hit CMD and hold down the Space Bar to send that folder location to Launchbar, select "Terminal" in Launchbar, then type

Code: Select all

./setup.py install


into the command line in Terminal and hit Enter. The module installs automatically.

Now do the same thing with the dateutil module.

2) Download the gcalcli script (again found at http://code.google.com/p/gcalcli/), unzip it and save it in Documents/Scripts. (You can, of course, save it anywhere you like, you'll just need to update my AppleScript with the new folder.)

3) Open the gcalcli script with TextEdit and insert your Google username and password in the appropriate spot in the script. (I use Google Apps for Your Domain, which works just fine with this -- if you do too, make sure you change the Calendar URL in my Applescript to "calendar.yourdomain.com" -- right now I have it set up for general Google users.)

4) Compile the script below using Script Editor and name it Quick Add to Google Calendar:

Code: Select all

on handle_string(s)
   set cmd to "~/Documents/scripts/gcalcli quick " & quoted form of s
   doTerminal(cmd)
end handle_string


on doTerminal(cmd)
   tell application "Terminal"
      activate
      if (count of (windows whose busy is false)) > 0 then
         set theWindow to first window whose busy is false
         set frontmost of theWindow to true
         try
            do script cmd in theWindow
         on error
            do shell script "/bin/sleep 5"
            do script cmd in the window
         end try
      else
         try
            do script cmd
         on error
            do shell script "/bin/sleep 5"
            do script cmd in the window
         end try
      end if
   end tell
   tell application "Safari"
      activate
      open location "http://calendar.alexwoolfson.com"
   end tell
end doTerminal


(I can't see how to attach files, but if someone knows how, I'll attach the script for those who are intimidated with compiling it using Script Editor. But again, it's really easy: copy the text above into a Script Editor window, click on the Compile icon in the tool bar and then Save As with "Quick Add to Google Calendar" anywhere you've told Launchbar to index.)

5) That's it! Now you can use Quick Add for Google Calendar with all its natural language goodness right from LaunchBar! Just summon up the script name in Launchbar, hit space and type in your event. Sorted!

I hope some people find this helpful. Again, all the thanks should go to the previous authors, I just tweaked their amazing work to do something I needed. I notice some people on this forum have been asking for iCal support from Launchbar. Well, this all started with me creating my own poor man's MobileMe using BusySync to sync iCal and my Google Calendars

http://www.busymac.com/

and GooSync to sync Google Calendar with my Treo

http://www.goosync.com/

So if I change the calendar in any one of them, they all get updated. Thus, I can use this script to quickly add events to my iCal using natural language right from LaunchBar -- and I get an online backup of my calendar data I can access anywhere on the web as well. If any of my fellow iCalers think this might be useful as well, I recommend you sign up for Google Calendar, try this AppleScript out and take a look at BusySync.

Cheers,

Alex

P.S. For those curious, a description of the kinds of language you can use with Quick Add can be found here

http://www.google.com/support/calendar/ ... 36604#text

bnmnetp
Posts: 1
Joined: Fri Oct 09, 2009 3:06 am

Re: Script for Quick Add to Google Calendar

Postby bnmnetp » Fri Oct 09, 2009 3:13 am

In LaunchBar 5 you can make this even simpler and avoid the whole applescript thing by using an x-launchbar url.

Add a new search template and in the Details column use the following:

Code: Select all

x-launchbar:execute?path=/your/path/to/gcalcli&arguments=quick+%22*%22


This will run the script directly.

alexjs
Posts: 1
Joined: Wed Mar 10, 2010 9:20 am

Re: Script for Quick Add to Google Calendar

Postby alexjs » Wed Mar 10, 2010 9:26 am

Is there any update to this? I tried using the Search Template option but it wouldn't work, no matter whether I put it in the ISO or UTF-8 Templates list. Then I thought I'd go about it the old fashioned way with an AppleScript, but the gcalcli downloads as an exe file and doesn't do anything when opened in Terminal.

Any help?

(I'm really looking for a way to add to iCal but I haven't found that, either. I use SpanningSync to sync my Google and iCal events.)

Cheers,
Alex

hhollick
Posts: 6
Joined: Fri Jan 22, 2010 6:59 pm

Re: Script for Quick Add to Google Calendar

Postby hhollick » Wed Mar 10, 2010 5:27 pm

bnmnetp wrote:In LaunchBar 5 you can make this even simpler and avoid the whole applescript thing by using an x-launchbar url.

Add a new search template and in the Details column use the following:

Code: Select all

x-launchbar:execute?path=/your/path/to/gcalcli&arguments=quick+%22*%22


This will run the script directly.


Could someone be so kind as to elaborate on bnmnetp's concise but cryptic instructions? I am assuming I need to substitute something for "/your/path/to/ . . . " but I have no idea how it works.

All I want to do is use Launchbar to insert an event in my Google Calendar using Google's Quick Add. It looks like it is doable in LaunchBar 5. The details elude me.

Many thanks for the help.

dwnfthr
Posts: 3
Joined: Thu Sep 16, 2010 8:53 am

Re: Script for Quick Add to Google Calendar

Postby dwnfthr » Thu Sep 16, 2010 8:57 am

In launchbar, find gcalcli. There will be a -- after it, and then some text, which will look like ~/Documents/Scripts. That is the path to gcalcli. In the code from bnmnetp, replace the "/Your/path/to" with the text specifying the path. So, you might get ~/Documents/Scripts/gcalcli.

JC
Posts: 17
Joined: Tue Apr 08, 2008 12:57 pm

Re: Script for Quick Add to Google Calendar

Postby JC » Wed Jan 12, 2011 5:52 pm

I can't find a "gcalcli" on my computer.

Has anyone else figured this out? Attempting to add an event to iCal (to a subscribed Google calendar) gives an error: "The server responded with an error."

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: Script for Quick Add to Google Calendar

Postby sjk » Thu Jan 13, 2011 2:06 am

JC wrote:I can't find a "gcalcli" on my computer.

It's not bundled with OS X; dwnfthr probably means the gcalcli Python app.


Return to “LaunchBar Actions”

Who is online

Users browsing this forum: No registered users and 1 guest