Miscellaneous ephemera…

Syncing with khal

Following up on my post from last week, about using khal and mutt, where I covered off a couple of simple hacks to integrate command line calendaring with Mutt, I had been using the main development branch of khal which includes syncing capability. However, as I was conversing with the developer, Christian, around a bug report, he indicated that this functionality would be superseded by development in a separate branch that uses vdirsyncer to synchronise calendars.

As Christian intimated that this change would happen in the very near future, and “js” had commented on my last post to the effect that it was working well, I thought I should take a look for myself.

There are packages in the AUR for vdirsyncer-git and python2-argvard so you will just need to grab the khal branch that uses vdirsyncer as it’s syncing engine. I have thrown up a PKGBUILD gist, or—as we are only talking about a couple of simple scripts—you could install the complete set using pip, the Python package manager; in which case it would be a straightforward:

sudo pacman -S python2-pip
pip2 install --user git+https://github.com/geier/khal.git@vdir
pip2 install --user vdirsyncer

…and then remember to make sure that $HOME/.local/bin is included in your $PATH.

I wanted to have vdirsyncer manage two of my calendars, my CalDav work calendar and a simple iCalendar with all of the New Zealand public holidays. Configuring vdirsyncer to successfully do this took me a lot longer than I would like to admit: a combination of my ineptitude, a bug and a broken schema in the original holidays.ics that I wanted to use.

The collections variable in the config file merits a mention in this regard. If you choose to use it, be aware that your URL will have this value appended to it, which may throw a 404. Using the DEBUG verbosity level will identify this issue if you are struck by it.

Eventually, with the help of both Christian and Markus, the vdirsyncer developer, I got it set up and running smoothly. I then just had to create a cron job to sync my work calendar every two hours and it was done.

As you would expect with such a simple tool, there is not a lot to say, or do, with vdirsycner. It runs on a similar model to OfflineIMAP, in that it synchronises a remote and local repository. There are a couple of nice touches: it will read your credentials from $HOME/.netrc so you don’t have to worry about sensitive information in plain text in yet another file, and there is a VDIRSYNCER_CONFIG variable, so you can place the config file wherever it suits.


Elevator, a Creative Commons image on Flickr by Mykl Roventine.