Linux: Linking Orage (XFCE4 desktop) to your Google Calendar.

What I am about to describe is a method that has worked for me on both PCLinuxOS (XFCE4 Community Edition) and MX-Linux (which uses XFCE4 by default). It ought to work on any version of Linux using the XFCE4 desktop (provided the necessary python dependencies are available — always the case as far as I know). Bear in mind, though, that there are no guarantees that it will work for you, or the sky will not fall on your head, or your computer won’t explode. You do this at your own risk.

If you are using a desktop other than XFCE4, this may not work!

0: Bad News, Good News.

Just to say that the developers of XFCE4 will not be supplying Orage with the coming version (4,14) of XFCE4. It’s not been worked on for some time. That’s the bad news. The good news is that the current version should still be available for download and will still work on the XFCE4 panel. It may have to be rebuilt by your distro, though. So nag them if it disappears.

1: Install python3-pip and vdirsyncer

Firstly use your Distribution’s installer (synaptic, for example) to install the package: python3-pip. Then you need to open a terminal, either as root or precede each line with sudo, and run the following two lines in it:

pip3 install vdirsyncer
pip3 install requests_oauthlib

This will install vdirsyncer in the folder /usr/local/bin for your use.

2: Opening your Google account up to vdirsyncer

If you have already done this, then you don’t need to do it again, instead, just move the files called config and google_token (hopefully in your folder ~/.vdirsyncer/) to somewhere safe, and skip to section 3.

Otherwise, log into the Google API dashboard:
https://console.cloud.google.com/apis/dashboard

Once there click on “+ ENABLE APIS AND SERVICES” near the top of the screen.

This takes you to a search screen, and in the search box, enter “caldav”. You will get a box to click on, “CalDAV API” which you should select. You will need to Create Credentials. In return, you will get two long IDs, client_id and client_secret.

Open your File Manager, and Show Hidden Files, click into .config and create a folder within that called vdirsyncer — and inside that create a text file called config.

You should create a folder under ~/.local/share/orage/ which is your gmail address (shown as youraddress@gmail.com in the file that follows).

config should look like this. You will use your own gmail address, client_id and client_secret, but everything else should be typed as I have. Note that WordPress may have changed quotemarks to Left and Right quotes and doublequotes. All quotemarks should be replaced by the normal upright ones. You may just have to retype them:

[general] 
status_path = "~/.vdirsyncer/status/" 

[pair mygoogle_calendar] 
a = "mygoogle_calendar_local" 
b = "mygoogle_calendar_remote" 
collections = ["from a", "from b"] 

[storage mygoogle_calendar_local] 
type = "singlefile" 
path = "~/.local/share/orage/youraddress@gmail.com/%s.ics" 

[storage mygoogle_calendar_remote] 
type = "google_calendar" 
token_file = "~/.vdirsyncer/google_token"
client_id = "1235467890abcdefghijklmnopqrstuvwxyz.apps.googleusercontent.com"
client_secret = "1234567890abcdefghijklmnop"

Now, make a folder in your home folder (not under .config) called “./vdirsyncer”, inside that, create another folder called “status”, and inside that, another folder called “calendar”.

That’s the preparation done…

Now for the moment of truth. You need to open a terminal, and run the following command as user:

vdirsyncer discover

A browser window should pop up to complete the authorisation, and that will create an access token, another long string of characters, which you need to copy to your clipboard. Meanwhile, the terminal goes into a “waiting” state. If you click on the terminal and hit a key, you will be prompted for the access token, which you should paste in. Keep an eye on the text that outputs to the terminal, in order to know that everything has gone ok.

Finally, you can run the following command as user to download your data files from Google for the first time:

vdirsyncer sync

Now jump to Section 4.

3. IF YOU HAD vdirsyncer SET UP BEFORE

Open your File Manager, and Show Hidden Files, click into .config and create a folder within that called vdirsyncer — and inside that, copy the text files you saved earlier called config and google_token.

Edit the config file to look like that shown in Section 2, keeping lines beginning client_id and client_secret as they are, and editing the line beginning path as it looks in Section 2 but of course using your own gmail address. Other lines should be changed to match the example in Section 2 if necessary.

You should create a folder under ~/.local/share/orage/ which is your gmail address (shown as youraddress@gmail.com in the file in Section 2).

Now, in a terminal as user, run the following command as user to download your data files from Google.

vdirsyncer sync

4. READING YOUR GOOGLE DATA INTO Orage

When vdirsyncer sync finishes, you should have one or more files in the folder “/home/your-user-name/.local/share/orage/youraddress@gmail.com/” which you can now link to orage.

You have to click on your panel orage time and date to bring up the calendar. You link the calendars by clicking on File>Exchange Data, and the tab called Foreign Files. Using the button “Open“, locate the folder and click on one of the ics files, with READ-ONLY clicked for now. Then click “Add”. When you have added one, try to locate some of its data both in your online Google Calendar and then by checking in Orage. Eventually you should see whether it’s a calendar that you’ll want to write stuff back to. If it is, click on Remove, uncheck Read-Only, change to a human-readable name in the “Visible Name” box, and Add again. It will now show as “READ-WRITE“. Repeat patiently for all calendar (ics) files.

In my own case, there was one I didn’t want, the main calendar in fact, which seems to add multiple copies of Birthdays, including long-forgotten ones, and loads of cruft. So I’ve excluded that from among the linked Calendars altogether. I have a separate Calendar called Diary, which I write all appointments in, and that is my only READ-WRITE. I have another Calendar specifically generated for Birthdays from my Google Contacts account, plus one for British Public Holidays and so on. These are READ-ONLY.

5. SETTING UP vdirsyncer CRON JOB

I suggest that you set the synchronisation up to run once an hour. It’s not that hard, but it involves a rather weird text editor so I’ll walk you through it. In this example, I’ve set the minute of the hour to 36. If you need to other hourly “Cron Jobs”, space them out. The only reason I suggest minute 36 is to get you used to the idea of not running them on the hour, you don’t want loads of them starting at once!

Open a terminal as user and run the command:

crontab -e

An editor opens and at the bottom add a line:

36 * * * * /usr/local/bin/vdirsyncer sync

All the “36” means is that the line runs on minute 36 of each hour, and the four stars mean every hour, every day of month, every month, and every day of week. I don’t want to have to do a full Crontab tutorial so keep it simple like this!

In order to save the change you do CTRL+O (letter O for output), and to exit, CTRL+X.

And that’s it.

6. ADDING APPOINTMENTS USING Orage

When you create a new entry using Orage, there is a pull-down menu which enables you to add it to any calendar you’ve marked as READ-WRITE. If you use the Orage Default File it will not upload to your Google Calendar. As you can see, I select the one I called DIARY.

orage-upload

If, when there is also stuff to be uploaded, you do see some worrying messages if you run vdirsyncer sync in a terminal, but ignore them. It will work. Just let it run in the background on the hour.

I will check this article for errors in due course, and may also add some screenshots. I hope this has been helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: