HOW-TO: Sync Orage with your Google Calendar.

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
davemx
Posts: 319
Joined: Sun Aug 12, 2018 2:31 pm

HOW-TO: Sync Orage with your Google Calendar.

#1 Post by davemx »

THERE'S A BETTER WAY OF DOING THIS — JUMP FORWARD TO THIS POST:

viewtopic.php?f=23&t=46232&p=504849#p504849

IGNORE THIS...

In order to sync Orage to your Google Calendar, the first thing you need to do is add a couple of programs. I've already discovered that the version of vdirsyncer in our repositories doesn't work. The latest stable version at their site doesn't work either for me. I got this working by installing this alpha version which seems to work OK:

https://packagecloud.io/pimutils/vdirsy ... _amd64.deb

You also need to install another program that's not in our repos called "requests-oauthlib". It's installed directly from the internet using a command line app called "pip", for which you need to install "python-pip" from Synaptic. Once you have done this, you can run this line in a terminal:

pip install requests_oauthlib

Before vdirsyncer will work, you will need to add "/opt/venvs/vdirsyncer-latest/bin/" to your $PATH. This can be done by adding (or amending an existing line) in the hidden file .bashrc in your home folder:

PATH=$PATH:/opt/venvs/vdirsyncer-latest/bin/
Last edited by davemx on Tue Jun 25, 2019 8:09 am, edited 3 times in total.
Desktop: Mini-Box M350 with Asus H110i-plus motherboard, Pentium G4600 processor, 2TB SSD and 16Gb RAM DDR4-2133
Printer/Scanner: Brother MFC-J5335W
Laptop: Lenovo V15 ADA
Media Centre: Lenovo Q190

davemx
Posts: 319
Joined: Sun Aug 12, 2018 2:31 pm

Re: HOW-TO: Sync Orage with your Google Calendar.

#2 Post by davemx »

You need to log in to 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.

At this point you need to create a folder inside your home folder called .vdirsyncer and a file inside that folder called config.

config should look like this. You will use your own client_ID and client_secret, but everything else should be typed exactly as I have:

Code: Select all

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

[pair calendar]
a = "google_calendar"
b = "local_calendar"
collections = ["from a", "from b"]
metadata = ["color"]

[storage local_calendar]
type = "singlefile"
path = "~/.calendars/%s.ics"

[storage google_calendar]
type = "google_calendar"
token_file = "~/.vdirsyncer/google_token"
client_id = "000000000000-abcdef0123456789ghijklmonpqrstuvwxyz.apps.googleusercontent.com"
client_secret = "1234567890_abcdef_wxyz"
Now, inside the folder ".vdirsyncer", create another folder called "status", and inside that, another folder called "calendar". That's the preparation...
Desktop: Mini-Box M350 with Asus H110i-plus motherboard, Pentium G4600 processor, 2TB SSD and 16Gb RAM DDR4-2133
Printer/Scanner: Brother MFC-J5335W
Laptop: Lenovo V15 ADA
Media Centre: Lenovo Q190

davemx
Posts: 319
Joined: Sun Aug 12, 2018 2:31 pm

Re: HOW-TO: Sync Orage with your Google Calendar.

#3 Post by davemx »

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

vdirsyncer discover calendar

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.

Once this is done, you need to make the first synchronisation. You do this by typing the next line into the terminal:

vdirsyncer sync

When the sync finishes, you should have one or more files in the folder "/home/your-user-name/.calendar" (not the one you created under .vdirsyncer) 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.

I linked them as READ WRITE but I am ready to be corrected because I'm not sure if that's right. At the moment I am getting down-syncing from Google OK but not up-syncing to Google, so if anyone can finish off this last bit for me?
Desktop: Mini-Box M350 with Asus H110i-plus motherboard, Pentium G4600 processor, 2TB SSD and 16Gb RAM DDR4-2133
Printer/Scanner: Brother MFC-J5335W
Laptop: Lenovo V15 ADA
Media Centre: Lenovo Q190

davemx
Posts: 319
Joined: Sun Aug 12, 2018 2:31 pm

Re: HOW-TO: Sync Orage with your Google Calendar.

#4 Post by davemx »

THIS DOESN'T WORK. SKIP FORWARD TO POST #9
https://forum.mxlinux.org/viewtopic.php ... 23#p459923


The other thing you need to do is to set up a cron-job. That's easy enough for, say, once an hour. In a terminal you run the command:

crontab -e

An editor opens and at the bottom you add a line:

36 * * * * 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.

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

That's just to get you started, read up on crontab and cron jobs for more ways of doing this.
Last edited by davemx on Fri Sep 07, 2018 5:21 pm, edited 2 times in total.
Desktop: Mini-Box M350 with Asus H110i-plus motherboard, Pentium G4600 processor, 2TB SSD and 16Gb RAM DDR4-2133
Printer/Scanner: Brother MFC-J5335W
Laptop: Lenovo V15 ADA
Media Centre: Lenovo Q190

User avatar
Jerry3904
Administrator
Posts: 21939
Joined: Wed Jul 19, 2006 6:13 am

Re: HOW-TO: Sync Orage with your Google Calendar.

#5 Post by Jerry3904 »

For people less enchanted with learning how to do a cron job on the command line, there is a very good GUI in the repos: gnome-schedule
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

davemx
Posts: 319
Joined: Sun Aug 12, 2018 2:31 pm

Re: HOW-TO: Sync Orage with your Google Calendar.

#6 Post by davemx »

Jerry3904 wrote: Thu Aug 30, 2018 4:35 pm For people less enchanted with learning how to do a cron job on the command line, there is a very good GUI in the repos: gnome-schedule
And it's already installed!
Desktop: Mini-Box M350 with Asus H110i-plus motherboard, Pentium G4600 processor, 2TB SSD and 16Gb RAM DDR4-2133
Printer/Scanner: Brother MFC-J5335W
Laptop: Lenovo V15 ADA
Media Centre: Lenovo Q190

User avatar
Jerry3904
Administrator
Posts: 21939
Joined: Wed Jul 19, 2006 6:13 am

Re: HOW-TO: Sync Orage with your Google Calendar.

#7 Post by Jerry3904 »

True, forgot that.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
stevedude
Posts: 68
Joined: Sat Aug 11, 2018 8:19 pm

Re: HOW-TO: Sync Orage with your Google Calendar.

#8 Post by stevedude »

Maybe not the most elegant solution but it was the easiest for me and it works. I created a bash script that I copied elsewhere online (sorry it's been a while and I don't have the reference). Just add your Google 'private' link from the Google Calendar website, save the script and make it executable, then I created a launcher for it.

It is manual, but whenever I add something to my Google Calendar I click on the launcher and they sync immediately. I created a 'Temp' folder under my home folder so change that path accordingly for your system.

#!/bin/sh
# Synch Google Calender w/ Orage.
# (1)
wget -nH -rK https://calendar.google.com/calendar/ical/YOUR PRIVATE CALENDAR LINK HERE -O /home/steve/Temp/googlecal.ics -a /home/steve/Temp/googlecal.log
# (2)
mv ~/.local/share/orage/orage.ics /home/steve/Temp/orage-backup.ics --backup
# (3)
cp /home/steve/Temp/googlecal.ics ~/.local/share/orage/orage.ics
#
OS:MX-19.2_x64|Kernel:4.15.0-1-amd64 x86_64|Xfce 4.14.2|Mobo:TUF X470-PLUS|CPU AMD Ryzen 5, 2600 MHz
Graphics:GeForce GTX 1060,driver:nvidia v:390.77|Audio:NVIDIA snd_hda_intel
Netwrk:Realtek RTL8111|Seagate:ST2000DM006, 1.82 TB|Mem:15.6 GB

davemx
Posts: 319
Joined: Sun Aug 12, 2018 2:31 pm

Re: HOW-TO: Sync Orage with your Google Calendar.

#9 Post by davemx »

The other thing you need to do is to set up a cron-job. There are banana skins here.

First, commands run by cron do not necessarily know your user's path definition. So it's necessary to use the full path to the executable file:

/opt/venvs/vdirsyncer-latest/bin/vdirsyncer

Secondly, and I don't understand why or how, but just because the file is executable by users, doesn't mean that cron will see it that way, so in a root terminal, make the following command. You need again to use the full path for this to work.

chmod 777 /opt/venvs/vdirsyncer-latest/bin/vdirsyncer

It makes no sense to me either, but it refused to work before I did this. It was a hint I found online.

To make it for once an hour, in a terminal you run the command:

crontab -e

An editor opens and at the bottom you add a line:

36 * * * * /opt/venvs/vdirsyncer-latest/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. If you have more than one hourly cron job, spread them out!

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

The other way to do this, is to run gnome-schedule which gives you a gui way of doing this (see posts above by Jerry3904) but you must still input the entire path to the required command, and not just "vdirsyncer sync". And you must still make the chmod command as shown.

That's just to get you started, read up on crontab and cron jobs for more ways of doing this.
Desktop: Mini-Box M350 with Asus H110i-plus motherboard, Pentium G4600 processor, 2TB SSD and 16Gb RAM DDR4-2133
Printer/Scanner: Brother MFC-J5335W
Laptop: Lenovo V15 ADA
Media Centre: Lenovo Q190

PPC
Posts: 362
Joined: Tue Sep 11, 2018 8:22 am

Re: HOW-TO: Sync Orage with your Google Calendar.

#10 Post by PPC »

I tend to make step by step instructions just in case I have to do stuff some time later.
Following the tips from stevedude (on entry number eight on this thread) I did a small tutorial that anyone case use to sync the calendar without even needing to see the command line, so even a newbie could do it:

Sync Orange Calendar with Google Calendar in 9 easy steps:

1- Open the File Manager [the Default, that I used was Thunar], click your Home folder - It should display /home/[username]
2- Menu - Create - Folder. Name the new folder "Temp" (without commas)
3- Get your Google Calendar private ICS file link by doing this:
- Open Firefox and go to https://calendar.google.com/calendar/r
- if needed, enter your google account username and password
-click The "Gear" icon (on the top right) -> Definitions -> on the left side click the calendar name (usually your user name) -> on the right side of the window scroll down to something like "secret Ical address" and copy the link there to a text file
-feel free to close that firefox tab, you don't need it anymore
4- Now (in my example) on your home folder, using your filemanager click File and create a new document. I choose to name my file "syncGC.sh"
5- Click that file and open it with a text editor (by default Featherpad)
6- Paste this text there (thanks stevedude and the anonymous folks that figured how to do this first):
#!/bin/sh
# Synch Google Calender w/ Orage.
# (1)
wget -nH -rK [your Ical Link] -O /home/[your user name]/Temp/googlecal.ics -a /home/[your user name]/Temp/googlecal.log
# (2)
mv ~/.local/share/orage/orage.ics /home/[your user name]/Temp/orage-backup.ics --backup
# (3)
cp /home/[your user name]/Temp/googlecal.ics ~/.local/share/orage/orage.ics
#
7- Correct the text inserting your username where it says "[your user name]" AND entering the Ical link you copied from Google Calendar beginning with HTTPS://... and ending with .../basic.ics where it says [your Ical Link]

8-make the file you created executable (i.e.- able to run like a program) by right clicking it on your file manager, clicking Properties - Permitions - and then checking the box on the bottom (it says something like allow this program to run...)

9-now sync the calendar (via a Launcher or Terminal):

9.1- Using the Graphics User Interface (you only have to create a link on the first run, then all you have to do is click it every time you want to sync your calendar)
-Right Click your desktop -> Create launcher -> a new window comes up.
I choose this options (replace [user name] by your own user name :-)):
Name: Sync
Comments: Sync Google Calendar
Command: home/[user name]/syncGC.sh
Icon: use the icon you like best. I liked office-calendar-symbolic
-Now, just click the launcher you just created. On the first run MX may show a warning. Click the button that refers to to "mark as executable" and the warning won't show up again...

9.2- Using the terminal: cd to your home folder and type ./syncGC.sh
wait for a couple of seconds (a warning pops up on the terminal) and you are done.

DONE : Check your orange calendar (clicking on the time that's on MX bar). You should see your appointments from Google Calendar (it may take a few seconds to load all your appointments)

You have to click the launcher or run the command from command line every time you want to sync Orange Calendar with your Google Calendar.

P.S.- About the privacy aspect of using Orange this way: I know Google makes money with all the data they gather on it's users and I value my privacy, I use duckduckgo, firefox, only sign into google when I have to... and I try to keep a low profile but... like many people I like the convenience of using Google Calendar on my mobile device and it's very, very convenient for me to also see my calendar on my pc and get the warnings there, to help schedule my day...). I'm a pragmatic person, using Google services like this, for me is a small trade off that I really don't mind doing, mostly because all the stuff that I schedule would be too cryptic to anyone else understand it...

P.
Last edited by PPC on Mon Oct 01, 2018 6:58 am, edited 2 times in total.

Post Reply

Return to “Tips & Tricks by users”