Friday, August 30, 2013

Sync Orage and Google Calendar

I wrote in my previous post that Orage, the calendar application in XFCE, does not Sync with Google Calendar. This is true, but there is a way to enable Orage to sync with Google Calendar, so that events added to Google Calendar will appear in Orage, but not the other way round.

To sync Orage with Google Calendar, it's possible to download Google Calendar in iCalendar format and import this into Orage.

To download the file, go to calendar settings and right click the green ICAL button next to Private Address.

Select Save Link As (or similar, according to browser) and save the file.

To import into Orage, Go to File > Exchange data > Foreign files, click the Open button, navigate to the saved file (basic.ics) and click Add. Events from Google Calendar will be added to any local Orage events.

To automate the process, we can use a cron command.
wget -N
The -N parameter will overwrite the file if it is newer on the sever, rather than adding files bacis.ics.1, bacis.ics.2 etc etc which we don't want.

To get the calendar URL, right click on the green ICAL button again but this time select Copy Link Location (or similar, according to browser).

Paste the address into a text editor to see it. There is a problem here because the Google email address that the URL contains will have been transformed into HTML URL Encoding,  so joesmith@gmail.com will have become joesmith%40gmail.com (see: Try It Yourself) and the % character will not work in a cron command. Edit %40 back to @, so the full command looks like this:
wget -N https://www.google.com/calendar/ical/joesmith@gmail.com/private-/basic.ics
Now we need to run the command once a day. Corenominal has a cron tutorial which covers this. Note: it may be necessary to specify the full path to wget with this method: /usr/bin/wget. I used a GUI application which uses cron to schedule tasks: Gnome-schedule, where the above command worked OK. Although it's a Gnome app, it installs in XFCE without needing any dependencies, and is simple to use.


The Run button didn't seem to work for me, perhaps because it is a Gnome app and is not properly configured to launch a terminal in XFCE. If you want to check your cron command is working, change Date & Time to Every minute and watch the basic.ics file appear in your home directory, then reset to daily, of course.

4 comments:

  1. That's what I've been looking for. Thanks for handy instruction.

    ReplyDelete
  2. I do the same thing, but use the following options, wget -T 5 -r -nH -nd -O /home/[username]/.local/share/orage/orage.ics [URL]. The -T 5 is a five second timeout, -r recursive, -nH and -nd is no hostname and no directory based upon the URL and path. This lets you specify the output directory and file name. Orage then always has your Google Cal updates. My cron job runs every hour.

    ReplyDelete
  3. Thanks to you and JM, this is good.

    ReplyDelete
    Replies
    1. and it Just Works™ in the unix spririt of things

      Delete