banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Linking Orage (Xfce4 Desktop) To Your Google Calendar


by davecs (Dave Spagnol)


When Google decided to tighten up security (a.k.a. made it difficult to get to your own data), I believed that I wouldn't be able to link orage to my data anymore. Numerous online searches showed that others had the same problem, lots of questions, but no answers. There is a vdirsyncer manual online, but I found it hard to follow. But I persisted with the manual, and eventually found the answer. It turns out the solution wasn't that difficult. All it involved was uninstalling the old version of vdirsyncer, and installing the up to date one. Then uninstalling requests-oauthlib, and installing python-aiohttp-oauthlib. And apart from that, not much had changed. I now have everything working again!

I have been testing the PCLinuxOS Debian Edition Xfce version, and it works without any problems up until now. My only worry is that vdirsyncer's access to my Google Calendar will be time-limited. At the time of writing, it seems OK. I have also tested it on standard PCLOS Xfce. It should also work on non-XFCE desktops, because Orage is no longer tied to the XFCE panel.


1: Install vdirsyncer and python-aiohttp-oauthlib You will need to install vdirsyncer, and python-aiohttp-oauthlib. You should be able to do this through your distro's normal installation method. Otherwise, you install python3-pip then install the packages online via python repositories. 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 line for each app:

pip3 install vdirsyncer
pip3 install aiohttp-oauthlib

(You don't include the “python-” part of the name if installing via pip3)

If using pip3 as root, you will get a message warning you that you may have a problem due it clashing with your distro's repository system, then it goes on to install it anyway. In the case of Texstar's PCLinuxOS, vdirsyncer and aiohttp-oauthlib are not available in the repository, so there is no clash.

If you have an old version that doesn't work anymore, you can use the command pip3 uninstall to uninstall vdirsyncer and requests-oauthlib, before re-installing vdirsyncer and aiohttp-oauthlib. I couldn't find another way to upgrade vdirsyncer to the latest version.


2: Opening your Google account up to vdirsyncer Click on https://console.cloud.google.com/apis/dashboard Once there click on “+ ENABLE APIS AND SERVICES” near the top of the screen. Ask for a new Desktop Application.

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. This part is a lot more complex than it used to be! You have to give your “project” a name and fill in all sorts of seemingly irrelevant information to get at your own data!

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).

You need to create a configuration file at /home/yourusername/.config/vdirsyncer/config which 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. All quote marks should be standard upright ones:

[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 mygoogle_calendar


A very off-putting browser window now pops up, I wish I had a screenshot of it. It's basically an error report, similar to the one when you try to log in to an insecure site, with two large buttons on the screen, the one on the right saying “back to safety” and the other leading you to pages purporting to explain what you have to do, but which add to the confusion. Ignore both these buttons, instead there is another link in very small print at the bottom. It might say “Advanced”, if it doesn't, it leads to another link that says “Advanced”. That's the one you have to click, and we go through to the authorization window.

A browser window should pop up to complete the authorisation, and that will create an access token, which will be saved as the file you set up as the “token_file”. Finally, you can run the following command as user to download your data files from Google for the first time:

vdirsyncer sync


3. LOADING 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.


Orage Exchange Linking

To get started, run orage, either via your start menu, or if you've already attached it to your panel clock, just click on that. 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. There should be one calendar that you'll want to write stuff back to. When you identify it, click on Remove, but remember the name it appears under in the files. You might also want to remove all of the files, and add them again, but with a human-readable name in the Visible Name box.

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 created another calendar specifically generated for Birthdays from my Google Contacts account, and another one for British Public Holidays and so on. I left these on the Foreign Files tab as READ-ONLY. I clicked on the “Orage Files” tab, and added the file that I want to write stuff back to, under “Orage Main Calendar File”. If there's more than one file you might want to write stuff back to, you can keep one in the Foreign Files section, but remember to untick Read Only before saving it to the list. If there is more than one file you can write to, you get a choice when you are entering a new appointment.


4. SETTING UP vdirsyncer CRON JOB

When setting up a schedule, in this case, to run command every hour, you should bear in mind that the standard paths don't always work. You must always type in the full path to vdirsyncer. Depending on how you installed it, it will be one of the following:

/usr/bin/vdirsyncer sync
/usr/local/bin/vdirsyncer sync
/home/yourusername/.local/bin/vdirsyncer sync
You should use your File Manager to take a look and see which one it is before proceeding.

Your distro may have a nice GUI to set up a cron job. I strongly recommend you use it. PCLinuxOS has gnome-schedule available, but PCLOS Debian uses job-schedulery. If you prefer, you can use the command line (as user, not root) in a terminal. I wouldn't recommend this if you are not used to using old-fashioned console text editors like Vi and Nano. This involves typing the line:

crontab -e
Whichever method you use, decide what minute of the hour you want the sync to take place. I use 36 out of habit. The minute is the first entry, followed by hour, day, month, and weekday. An asterisk means “any” so to make it 36 minutes every hour, your line reads:
36 * * * *
Then it needs the full path to vdirsyncer. If you installed via your distro's repository, it's likely to be /usr/bin/ but if you installed it using pip3, then it might be /usr/local/bin — check it via your file manager. So your line in crontab could be one of these:
36 * * * * /usr/bin/vdirsyncer sync
36 * * * * /usr/local/bin/vdirsyncer sync
36 * * * * /home/yourusername/.local/bin/vdirsyncer sync
All you need to do is to arrow down past all the hashed lines, then type it in. When you've done this, you need to save it!


Using a GUI like gnome-schedule


New task window
New task window in gnome-schedule

If you're using a program like “gnome-schedule” or “job-scheduler”, look at the illustration. If you install gnome-schedule using synaptic, it appears in the start menu as “Scheduled tasks”. Once you've installed it, run it. Adding your task is simple enough. Just click on “New” and then select “A task that launches recurrently”. You get the Dialogue box shown. Note that when you add the name of the program, you need to include the full path, as shown above.

I suggest that you set the synchronization up to run once an hour, which is the basic default. If you have other scheduled tasks which need to run once an hour, set them at different minutes so they don't all put a load on your system at the same time.


Job Scheduler window
Job Scheduler window


5. ADDING APPOINTMENTS USING Orage

When you create a new entry using Orage, (File>New from the calendar), the entry you make is added to the Orage Main Calendar File you declared earlier. If you also have a Read-Write file on your “Foreign Files” tab, you will get a choice as to where it goes (a drop-down menu near the top of the window). Once an hour when vdirsyncer runs, data will be merged with the copy at Google!

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!


6. Adding Orage to your panel clock

If you are using Orage with XFCE (>=4.18) or another Panel whose clock supports running a command when clicked, you might want to add Orage to your panel clock, see last month's magazine.

(We'd like to thank davecs for allowing The PCLinuxOS Magazine to reproduce this article from his blog, at https://davespagnol.wordpress.com/2024/07/07/linux-linking-orage-xfce4-desktop-to-your-google-calendar/)



Previous Page              Top              Next Page