Notes on seeking wisdom and crafting software

Sync caldav tasks with vdirsyncer

If you’re using Nextcloud for your intranet (files, photos, calendar etc.), vdirsyncer and todoman may be an interesting addon to the workflows. vdirsyncer syncs the caldav based tasks and calendar items to your local desktop and todoman is a command line todo list manager for caldav items. This post will cover some notes on this setup.

Official setup guide is simple and available as a tutorial. Here’s my config for vdirsyncer.

# vdirsyncer configuration: ~/.vdirsyncer/config
[general]
status_path = "~/.vdirsyncer/status/"

[pair cal]
a = "cal_remote"
b = "cal_local"
collections = ["from a", "from b"]
conflict_resolution = "a wins"

[storage cal_local]
type = "filesystem"
path = "~/.vdirsyncer/arun"
fileext = ".ics"

[storage cal_remote]
type = "caldav"
url = "https://mynextcloudhost.local/remote.php/dav/"
username = "arun"

# create an app password at https://mynextcloudhost.local/settings/user/security
password = "some-app-password"

# retrieve this with `echo -n | openssl s_client -connect mynextcloudhost.local:443 | openssl x509 -noout -fingerprint`
verify_fingerprint = "87690337bxa9cd454ef265615g79b7f9z8zzf356"

First, validate this setup with vdirsyncer discover and vdirsyncer sync from the terminal.

Next, we’ll use systemd user service to automatically sync the remote and local calendars. The instructions for this were a bit difficult to find: https://vdirsyncer.pimutils.org/en/stable/tutorials/systemd-timer.html

Here are the service files and steps.

# save to ~/.local/share/systemd/user/vdirsyncer.timer
[Unit]
Description=Run vdirsyncer hourly

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target
# save to ~/.local/share/systemd/user/vdirsyncer.service
[Unit]
Description=Sync calendars and addressbooks with vdirsyncer
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/bin/vdirsyncer sync

Enable the service as shown below.

> systemd --user enable vdirsyncer.timer
> systemd --user start vdirsyncer.timer

Use todoman to list your tasks. Here’s my configuration.

# save to ~/.config/todoman/todoman.conf
# See https://todoman.readthedocs.io/en/stable/configure.html
[main]
path = ~/.vdirsyncer/arun/*
default_list = inbox-1

# vim: set ft=ini

Additionally, if you use Android, do check out the awesome opensource Tasks app. It works flawlessly with Nextcloud and the above setup.