There are multiple way to work with Google Calendar.
I choose to not work with the private key thing for now.
Instead I will try to use the option working with the
This should give a relatively universal solution for all kind of calendars.
I don’t want a locked-in solution that would work only for Google.
(Not that this would very surprising if in the end we find out we have to do something custom because it’s google)
Google offer a private URL you can use to access your calendar read only.
In your Setting > Settings for my calendars > Calendar Name > Integrate calendar
Unhide the stars and you will get the secret address of your ical file for your calendar.
This can then be parsed into an org file using the following script.
It does require
awk installed on your machine, but this is quite standard, so not a problem.
somehow would be nice to re-write this using python or go, but it’s left as an exercise to the reader.
The logic is quite simple:
- download the ics file
- convert to org
- do this every 15 min in a cron
#!/bin/bash ICAL2ORGFILE="<path to orgfile>" GOOGLE_CAL_URL="<url to your private Google calendar>" source ~/.ical2org.rc # private with actual values wget -O /tmp/basic.ics $GOOGLE_CAL_URL awk -f ~/.local/share/ical2org.awk< /tmp/basic.ics > $ICAL2ORGFILE
In order to help with the setup I have written a quick install script
#!/bin/bash ICAL2ORGFILE="<path to orgfile>" GOOGLE_CAL_URL="<url to your private Google calendar>" read -r -p "Enter path to orgfile > " ICAL2ORGFILE read -r -p "Enter URL to Google Calendar > " GOOGLE_CAL_URL export ICAL2ORGFILE export GOOGLE_CAL_URL echo "ICAL2ORGFILE=$ICAL2ORGFILE" > ~/.ical2org.rc echo "GOOGLE_CAL_URL=$GOOGLE_CAL_URL" >> ~/.ical2org.rc cp ./ical2org.awk ~/.local/share/ cp ./ical2org.sh ~/.loca/bin/
It requires you to have a
.local/ folder, with
it is quite common on linux install, but feel free to modify it to fit your local thing.
Why read-only ?
One thing I want to get out of the way is the reason why I am not looking for a bi-directional synchronisation.
There are ways to do sync google calendar both way with org-agenda, if you are into that sort of things.
But I decided not to.
The reason is quite simple.
Org mode is the ground zero, where the work is happening.
It is a very dynamic and flexible environment.
Google calendar on the other hand is a dedicated to just one aspect of the workflow, and I don’t want to limit myself in org-mode just so that I can synch back.
All in all, I don’t have that many event, and usually adding events happen directly into the calendar.
So if I am not gonna need it, I prefer to avoid it. Less bugs and problems to fix.
I have put all the source code for this little project in here