When I started looking for a terminal calendar application the primary result was calcurse. Calcurse has also an integrated todo list, which I in my particular case don't need, because I got todo.txt for that. But uses it's own plaintext for storing it's appointments. Which is problematic for me when I want to use my existing calendar from Nextcloud. Calcurse has experimental caldav support, but the import and export scripts did not work properly for me and just messed my calendar up by creating broken calendar cards and doubling all my events each sync.
Khal is my solution. It is similar to khard, a terminal vcard contact book. Both applications work perfectly with vdirsyncer together. The only packages required are vdirsyncer and khal. Ond Arch linux they can pe installed using pacman.
sudo pacman -S vdirsyncer khal
Otherwise i'd recommend pip.
pip install vdirsyncer khal
Synchronize with nextcloud
First of all I add the vdirsyncer synchronisation.
~/.config/vdirsyncer/config
[pair calendar] a = "calendar_local" b = "calendar_remote" collections = ["from a", "from b"] metadata = ["displayname"] [storage calendar_local] type = "filesystem" path = "~/.calendar" fileext = ".ics" [storage calendar_remote] type = "caldav" #Can be obtained from nextcloud url = "https://yournextcloud.example.lcl/remote.php/dav/calendars/USERNAME/personal/" username = "<USERNAME>" #Instead of inserting my plaintext password I fetch it using pass password.fetch = ["command", "pass", "nextcloud"] #SSL certificate fingerprint verify_fingerprint = "FINGERPRINT" #Verify ssl certificate. Set to false if it is self signed and not installed on local machine verify = true
The SSL certificate fingerprint can be obtained by the following line
echo -n | openssl s_client -connect your.calserver.lcl:443 | openssl x509 -noout -fingerprint
Now we can run vdirsyncer discover to create the necessary directories to then synchronize with vdirsyncer sync. I recommend to setup a cronjob for vdirsyncer sync to stay synchronized.
Configure khal
The thing left to do is to tell khal where our calendar is and some other things to display.
~/.config/khal/config
[calendars] #Can contain as many calendars as we want [[personal]] path = ~/.calendar/CALENDARNAME type = calendar priority = 2 color = dark green [default] #Set calendar used for new events when no one is given default_calendar = personal #Color dates when containing an event highlight_event_days = true #Timespan of days whose events are shown in e.g. list timedelta = 7d #Set printing of dates [locale] timeformat = %H:%M dateformat = %m/%d/%Y longdateformat = %m/%d/%Y datetimeformat = %m/%d/%Y %H:%M longdatetimeformat = %m/%d/%Y %H:%M
ikhal (interactive khal) gives us then this nice prompt. It is shipped with khal and khal interactive has the same effect
Keybindings for khal
Key | Function |
---|---|
d | delete selected event |
e | export selected event as ics file |
d | duplicate selected event |
E | edit selected event in $EDITOR |
v | visual selection(vim like) |
n | create new event |
q | quit |
t | select today |
enter | show and edit details of event |
meta enter | save edited event |
j, down | move cursor down |
k, up | move cursor up |
h, left | move cursor left |
l, right | move cursor right |