Tools Calendar Sync Lead image: Photo by jason hafso on Unsplash
Photo by jason hafso on Unsplash
 

Open source calendar synchronization

Synchronicity

If you use your Google account to synchronize appointments between your smartphone and your desktop computer, you can do this just as easily with an open source solution. By Kristian Kißling

Almost everyone has a Google account, so synchronizing calendars (such as your Thunderbird calendar) between your computer and an Android device with Google seems like an obvious solution. If you enter a date on your Thunderbird calendar, it automatically appears on your smartphone calendar. However, this choice comes with drawbacks: Google makes its money by collecting and evaluating your data, among other things.

Luckily, an alternative based on open source software gives you another option. This alternative option involves Nextcloud [1] on the server, Thunderbird and its Lightning Calendar extension on the desktop [2], and DAVx5 [3] and Etar [4] on the Android device. I did not test the Nextcloud alternative ownCloud [5], but calendar sharing may also work with ownCloud due to its similarity to Nextcloud.

In Figure 1, the user (Kris) shares a calendar (see the box "Sharing Several Calendars") with other users (Alice and Bob) The shared calendar ends up on the Android devices of all participants, as well as on their desktops, which are also running Thunderbird and Lightning in this test. All participants have their own Nextcloud accounts to store their calendars. This not only offers the option of securing the calendars with access data, but each participant can also opt out of the shared calendar and run their own calendars to which other users have no access.

Kris shares a calendar with Alice and Bob. Their devices then access the shared calendars via their individual Nextcloud accounts.
Figure 1: Kris shares a calendar with Alice and Bob. Their devices then access the shared calendars via their individual Nextcloud accounts.

I tested the Nextcloud instance on a virtual server on the web, but this is not a requirement. An alternative is to have Nextcloud hosted by a third-party provider. However, your calendar data might end up with the third-party provider, which is not desirable.

You can choose to run the Nextcloud software on a private network, such as network-attached storage (NAS) or a Raspberry Pi. The disadvantage is that if the calendars cannot be accessed via the Internet, they only synchronize when the users' smartphones and computers connect to the private network. Using port forwarding, DDNS, and NAS-specific solutions can remedy this by making a private Nextcloud instance accessible via the Internet.

Adding a Calendar

I will show calendar sharing using two calendars: one with holidays (MyHolidays), which the admin keeps private, and one with appointments (OurDates), which is shared with other users.

I'll assume that you, functioning as the calendar admin, have already installed the Lightning Calendar extension in Thunderbird (using Thunderbird 68.10.0 installed with Ubuntu 20.04) and are running a calendar locally.

To open the calendar view, go to Appointments and Tasks | Calendar or use Ctrl+Shift+C. Next, select the existing calendar with appointments on the left, right click on it, and choose Export Calendar. This creates an .ics file, which you will store as OurDates in a folder. For the MyHolidays calendar, you can download a ready-to-use ICS file [6] from the Internet.

Nextcloud Calendar Setup

Next, you need to integrate the calendars into Nextcloud. The calendar app may still be missing in Nextcloud. To install the calendar app, log in as the Nextcloud administrator, click on the profile picture top right, and select Apps from the drop-down menu. Then locate the Calendar app and enable it. A calendar icon now should appear in the top pane of all Nextcloud accounts.

You can go ahead and create your two calendars in the Nextcloud admin account, but this would require giving Thunderbird and DAVx5 the Nextcloud admin's access data so that the programs can access the calendars. To avoid this unnecessary risk, you should create a separate Nextcloud account for each user that only manages the calendars.

Next, you create a new user account for yourself (kris in the example) and two employees (alice and bob) by selecting User from the menu in the upper right corner. Then you log off as admin and log on again as kris. A click on the calendar icon in the menubar at the top opens the calendar on the screen.

In the calendar view, you will see a calendar named Personal. Ignore this and click on New Calendar | New Calendar with Task List and create two empty calendars named OurDates and MyHolidays.

Next, you import the local ICS files into your kris profile by clicking on Settings & import in the lower left corner and then on Import Calendar. Search the hard disk for the MyHolidays.ics file and click Open. An import window prompts you to decide which calendar to use to import MyHolidays.ics. On the right side of the window, the two calendars created in Nextcloud are available for selection. Choose MyHolidays and then repeat the procedure for OurDates. Depending on the number of appointments, the import can take a couple of minutes. Finally, the dates appear in the Nextcloud calendar (Figure 2).

After importing the two ICS files from the kris profile, the dates appear in the Nextcloud calendar.
Figure 2: After importing the two ICS files from the kris profile, the dates appear in the Nextcloud calendar.

Sharing Calendars

To now share the OurDates calendar as the user kris with Alice and Bob, just click on the link-sharing icon to the right of the calendar name. An input field appears where you first enter alice to share the calendar with Alice. Nextcloud automatically completes the profile name. Check the Can edit box and then click on the empty space below the calendars. Repeat this procedure for Bob (entering bob). When Bob and Alice log in to their Nextcloud accounts, they will find the shared calendar waiting for them.

Remain logged in as kris to integrate your Nextcloud calendars in Thunderbird and Android in the next step. For this, you need the direct link to the calendars. To the right of the calendar name, click on the symbol with the three dots and choose Copy private link. The links for the two calendars should look like the ones shown in Listing 1.

Listing 1: Calendar Links

https://nextcloud.<example.com>/remote.php/dav/calendars/kris/ourdates/
https://nextcloud.<example.com>/remote.php/dav/calendars/kris/myholidays/

Armed with these URLs, you now switch to Thunderbird and again call the calendar module. A right-click on the free space below opens a selection menu. Choose New Calendar, which displays a window where you can include either a local or a remote calendar. Select On the Network and click Next.

In the next window, select CalDAV for Format and paste the first URL from Listing 1 to access the Nextcloud calendar (Figure 3). You can then customize your calendar by entering a name, selecting a color, checking the Show Reminders box, and entering an email address that matches the calendar.

Thunderbird's calendar expects a private link to the Nextcloud calendar followed by kris's login data in the next window.
Figure 3: Thunderbird's calendar expects a private link to the Nextcloud calendar followed by kris's login data in the next window.

A click on Next finally takes you to a login window, where you enter the access data for the kris Nextcloud account. The calendars now appear on the left side of the Lightning module in Thunderbird.

Alice and Bob follow the same procedure, each logging on to Nextcloud and copying the links to their calendars. Their links differ (Listing 2) from those shown in Listing 1. Alice and Bob provide their own Nextcloud credentials during the final step of Thunderbird configuration.

Listing 2: Bob's Calendar Links

https://nextcloud.<example.com>/remote.php/dav/calendars/bob/ourdates_shared_by_kris/
https://nextcloud.<example.com>/remote.php/dav/calendars/bob/myholidays/

Android Access

To synchronize the calendars with Android smartphones, all three users need to install the WebDAV app DAVx5 and the Etar calendar from F-Droid [7], both of which are released under the GPLv3. To do this, you need to install F-Droid first and then update it. In addition, F-Droid users must always (once or permanently) enable the Unknown Sources option in Android when installing any applications.

If you don't have F-Droid on your smartphone (and don't want it), you can also purchase DAVx5 for a small fee from the Google Play Store. Alternatively, you can use the calendar app preinstalled on your smartphone as a calendar. If you are using Etar, you should deactivate or uninstall the existing calendar first.

After launching, DAVx5 runs a wizard. Among other things, you must give DAVx5 the appropriate rights so that it works as desired. If you agree to the wizard's suggestions, you will end up in a window for setting up CalDAV accounts. Clicking the plus symbol opens another window where you should select Login with URL and user name. Enter the lines shown in Listing 3 for the user kris. Be careful: In the first line, there should be no specific calendar name at the end.

Listing 3: DAVx5 Configuration

https://nextcloud.<example.com>/remote.php/dav/calendars/kris/
kris
<Password>

In the next screen, DAVx5 links the transferred Nextcloud account with its own account and names it after the Nextcloud user's email address. In the DAVx5 main window, you then click on the new orange DAVx5 account. Under the CALDAV tab, DAVx5 lists all calendars found on the kris Nextcloud account (Figure 4). You then select the calendars that you want Etar to manage (MyHolidays and OurDates) and finally click on the orange arrows to synchronize them. Etar then automatically integrates the active DAVx5 calendars (Figure 5).

DAVx5 lists the calendars found on Nextcloud. You need to activate and synchronize them.
Figure 4: DAVx5 lists the calendars found on Nextcloud. You need to activate and synchronize them.
The Etar open source calendar then displays the calendars without further ado; you can see an overview of upcoming appointments.
Figure 5: The Etar open source calendar then displays the calendars without further ado; you can see an overview of upcoming appointments.

You can also do some fine tuning in the DAVx5 account by clicking on the account and then on the gear wheel in the top right corner. For example, you can determine how often DAVx5 checks for new appointments.

Conclusion

The solution shown here has been running stably and smoothly on several Android and Linux devices for some time now. Appointments, as well as tasks, can be entered anywhere and at any time and are quickly synchronized. DAVx5 also offers the possibility (not tested in our lab) to synchronize contacts and integrate Webcal calendars. On Android devices, however, Etar is not a requirement. The standard calendar usually recognizes the DAVx5 account, too. In addition, further (open source) calendar apps are available from F-Droid and the Google Play Store.