3 minutes reading posted in linux
Calendar sync via command line
I’m currently revising how I’m using my tools and try to removed distractions. One significant source of distraction is Thunderbird because whenever I want to create an appointment or want to check my upcoming events, I instead open the Mail view first and start to read mails. The solution is to move my calendar into a separated application. One thing I favour is having the tool for the command line.
After some searching, the following tools can be found:
There is another tool
pcal that might could fit, however, it does not support calendar sync like a owncloud.
khal you could get it via
pip, but also
For the Installation via archlinux:
pip install khal
or get the
pip install git+git://github.com/geier/khal.git
or from archlinux:
pacman -S khal
The next step is to define the endpoints for the configuration. This file is located to in
.config/khal like this:
[calendars] [[home]] path = ~/.calendars/home/ color = green [[work]] path = ~/.calendars/work/ readonly = True
There is a good documenation about this from Eric Scheibler. He provides an example for fetchin to have a better basic:
mkdir ~/.config/khal wget -O ~/.config/khal/khal.conf https://github.com/geier/khal/raw/master/khal.conf.sample
I’ve updated it reflect my configuration a bit:
[calendars] [[calendars]] path = ~/.calendars/* type = discover color = dark green [locale] local_timezone= Europe/Berlin default_timezone= Europe/Berlin timeformat= %H:%M dateformat= %d.%m. longdateformat= %d.%m.%Y datetimeformat= %d.%m. %H:%M longdatetimeformat= %d.%m.%Y %H:%M [default] default_calendar = personal timedelta = 7d # the default timedelta that list uses highlight_event_days = True
What your doing here is point out to folder where the calendars is located for display. But how does the calendar get there? For this we have another tool, called
You have to install it, similar like
khal, but I keep the installation via
pacman -S vdirsyncer
Again I’m using the example from Eric Scheibler with
vdirsync. However it’s a little bit out-dated. I had to tinker around a bit to get it running. The essential is the
[general] status_path = "~/.vdirsyncer/status/" # CALDAV [pair calendar] a = "calendar_local" b = "calendar_remote" collections = ["university","personal", "contact_birthdays", "prüfung" ] conflict_resolution = "b wins" [storage calendar_local] type = "filesystem" path = "~/.calendars/" fileext = ".ics" [storage calendar_remote] type = "caldav" url = "https://owncloud.akendo.eu/remote.php/dav/" #auth = "digest" #verify = /etc/ssl/local/example.org.pem username = "akendo" password = "<reacted>" start_date = "datetime.now() - timedelta(days=365)" end_date = "datetime.now() + timedelta(days=365)"
One issue that remains in here is that the password is stored in plaintext. But I think Thunderbird does essentially the same. Here two things to consider:
end_date are time frame how old an event in your calendar should be synced. In this example, I get all events that are older one year.
collections defines the calendar that should be synchronised. Important is the keyword for
conflict_resolution. In case an event exists remote and locally,
here we set the default policy to handle the conflict. On our instance, we do not use the local change.
Once the configuration is completed we try to run
vdirsyncer discover calendar to see what type of calender are present on our URL endpoint. At first, it take some attempts to get this going. When you need to reset the state, you can remove the folder
.vdirsyncer/ to reset to a clean state.
When the right calendars are discovered to your locale system you can synchronise the events of it via:
Keeping it syncing
One down side so far is that the
vdirsyncer sync is one time. You have to manual sync it from time to time. You can create this via
That’s all for today.
best regards, akendo