Calindori and online calendars

Δεκ 30 2020

Currently, Calindori works with calendar data provided by files that follow the iCalendar specification, without offering an out-of-the-box way to synchronize your calendars with external sources, e.g. with Nextcloud. However, this will change in the future. In specific, a plan for this feature has been devised. The first step, a plugin interface that will enable Calindori to use calendar data from various data sources is already in progress.

Although Calindori works on Linux mobile, desktop and even Android, it has been created as the calendar of Plasma Mobile. From this point of view, as soon as a personal information management (PIM) system is available on Plasma Mobile, Calindori will make use of it. However, such a system has not been implemented yet. Various ideas have been discussed on the Plasma Mobile sprints and community meetings. Personally, I am in favor of a sustainable, KDE community driven solution that will work well with Plasma desktop as well as taking into account the particularities of the mobile world, e.g. low energy consumption, "deep sleep" support, etc.

Calindori desktop Calindori on desktop

That being said, let me describe here an online calendar synchronization approach that has worked well for me. My personal workflow consists of a personal Nextcloud server -where my calendar is hosted- and various devices that make use of the Nextcloud calendar. As I said in the beginning, Calindori uses iCalendar files for calendar data. Thus, I looked for a mechanism that uses iCalendar files and synchronizes them with Nextcloud. During my research for such a solution, I stumbled upon Vdirsyncer.

As the home page of the project reads, Vdirsyncer is a "command-line tool for synchronizing calendars and address books between a variety of servers and the local file system". Let me now describe how I managed to configure it and make it work with Calindori.

Certainly, the first necessary step is to install Vdirsyncer. Luckily, it is available in various Linux repositories. E.g, on Ubuntu you just have to install the vdirsyncer package. Next, according to the project documentation, a configuration file should be created. So, I created this config file in the ~/.config/vdirsyncer directory:

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

[pair nc_myusername_caldav]
a = "nc_myusername_caldav_local"
b = "nc_myusername_caldav_remote"
collections = ["from a", "from b"]
metadata = ["color"]
conflict_resolution = "b wins"

[storage nc_myusername_caldav_local]
type = "singlefile"
path = "~/.local/share/vdirsyncer/caldav/myusername/%s.ics"

[storage nc_myusername_caldav_remote]
type = "caldav"
url = "https://mynextcloudhost.xyz/remote.php/dav/calendars/myusername/personal/"
username = "myusername"
password.fetch = ["command", "keyring", "-b", "keyring.backends.kwallet.DBusKeyring", "get", "Nextcloud", "myusername:https://mynextcloudhost.xyz/:0"]

So, in the configuration file, I defined two storages: - nc_myusername_caldav_local, the local iCalendar file that Calindori will "consume" and the - nc_myusername_caldav_remote, the Nextcloud personal calendar.

The pair nc_myusername_caldav section makes Vdirsyncer synchronize the calendar storages bidirectionally. In case of a conflict -an event or task has changed on both sides since the last sync- I opted for the conflict to be resolved in favor of the remote storage.

With regards to authentication to Nextcloud for user myusername, keyring has been used in order to access the kwallet subsystem via D-Bus.

KDE Wallet KDE Wallet Nextcloud entry

This approach works perfectly for me since various passwords that I daily use have been stored in the kwallet which is opened just after logging in to my user session. If this approach does not fit your needs, there are various alternatives.

Then, after creating the ~/.local/share/vdirsyncer/caldav/myusername directory and running:

vdirsyncer discover
vdirsyncer sync

an iCalendar file will be created and populated with your Nextcloud tasks and events.

The next step is to synchronize automatically at certain intervals. So, if you - download vdirsyncer.service and vdirsyncer.timer - put them into ~/.local/share/systemd/user - activate and run the timer

systemctl --user enable vdirsyncer.timer
systemctl --user start vdirsyncer.timer

the Nextcloud calendar will be synchronized every 15 minutes.

Finally, we need to let Calindori know about the Nextcloud calendar. The process is straight forward: navigate to Settings > External > Add and add the Vdirsyncer calendar file. From now on, the tasks and events that are created either on Calindori or Nextcloud side are going to be synchronized between each other.

Add external calendar Add an external calendar

Finally, let me clarify that this approach is not the way that Calindori and Plasma Mobile are going to offer online synchronization of calendars in the future. Nevertheless, Vdirsyncer is a nice, simple utility that enable users to use Nextcloud calendars in Calindori at the moment. It has worked pretty well for me, and I think that the Linux-on-mobile community will find it as an interesting solution for calendar synchronization.