khal¶
Khal is a calendar program for the terminal for viewing, adding and editing events and calendars. Khal is build on the iCalendar and vdir (allowing the use of vdirsyncer for CalDAV compatibility) standards.

Features¶
(or rather: limitations)
- khal can read and write events/icalendars to vdir
- fast and easy way to add new events
- ikhal (interactive khal) lets you browse and edit calendars and events
- recurring events cannot be deleted (neither single instances nor the whole event)
- you cannot edit the timezones of events
- khal should run on all major operating systems [1] (has been tested on FreeBSD and Debian GNU/Linux)
[1] | except for Microsoft Windows |
Table of Contents¶
Installing khal¶
If khal is packaged for your OS/distribution, using your system’s standard package manager is probably the easiest way to install khal.
If a package isn’t available (or it is outdated) you need to fall back to one of the methods mentioned below.
Install via Python’s Package Managers¶
Since khal is written in python, you can use one of the package managers available to install python packages, e.g. pip.
You can install the latest released version of khal by executing:
pip install khal
or the latest development version by executing:
pip install git+git://github.com/geier/khal.git
While this should take care of installing all required dependencies, installing lxml may fail. In that case have a look under Requirements. This should also take care of installing all required dependencies.
Requirements¶
khal is written in python and, at the moment, only runs in python 2.7. Make sure you have sqlite3 (normally available by default), icalendar, urwid (>0.9), pyxdg, vdirsyncer installed.
If you are installing python via pip or from source, be aware that since khal indirectly depends on lxml you need to either install it via your system’s package manager or have python’s and libxml2’s headers development packages installed.
Configuring khal¶
khal reads configuration files in the ini syntax, meaning in understands keys separated from values by a =, while section and subsection names are enclosed by single or double square brackets (like [sectionname] and [[subsectionname]].
Location of configuration file¶
Khal is looking for a configuration file named khal.conf in the following places: in $XDG_CONFIG_HOME/khal/ (on most systems this is ~/.config/khal/ by default), ~/.khal/ and in the current directory. Alternatively you can specifiy with configuration file to use with -c path/to/config at runtime.
The [calendars] section¶
The [calendars] is mandatory and must contain at least one subsection. Every subsection must have a unique name (enclosed by two square brackets). Each subection needs exactly one path setting, everything else is optional. Here is a small example:
[calendars]
[[home]]
path = ~/.calendars/home/
color = green
[[work]]
path = ~/.calendars/work/
readonly = True
- color
khal will use this color for coloring this calendar’s event. Depending on your terminal emulator’s settings, they might look different than what their name implies.
type: option, allowed values are black, white, brown, yellow, dark grey, dark green, dark blue, light grey, light green, light blue, dark magenta, dark cyan, dark red, light magenta, light cyan and light red default: None
- path
the path to a vdir where this calendar is saved
type: string default: None
- readonly
setting this to True, will keep khal from making any changes to this calendar
type: boolean default: False
The [sqlite] section¶
- path
khal stores its internal caching database here, by default this will be in the $XDG_DATA_HOME/khal/khal.db (this will most likely be ~/.local/share/khal/khal.db).
type: string default: None
The [locale] section¶
The most important options in the the [locale] section are probably (long-)time and dateformat.
- encoding
set this to the encoding of your terminal emulator
type: string default: utf-8
- local_timezone
khal will show all times in this timezone If no timezone is set, the timezone your computer is set to will be used.
type: timezone default: None
- unicode_symbols
by default khal uses some unicode symbols (as in ‘non-ascii’) as indicators for things like repeating events, if your font, encoding etc. does not support those symbols, set this to False (this will enable ascii based replacements).
type: boolean default: True
- longdateformat
khal will display and understand all dates in this format, it should contain a year (e.g. %Y) see timeformat for the format.
type: string default: %d.%m.%Y
- longdatetimeformat
khal will display and understand all datetimes in this format, it should contain a year (e.g. %Y) see timeformat for the format.
type: string default: %d.%m.%Y %H:%M
- default_timezone
this timezone will be used for new events (when no timezone is specified) and when khal does not understand the timezone specified in the icalendar file. If no timezone is set, the timezone your computer is set to will be used.
type: timezone default: None
- datetimeformat
khal will display and understand all datetimes in this format, see timeformat for the format.
type: string default: %d.%m. %H:%M
- timeformat
khal will display and understand all times in this format, use the standard format as understood by strftime, see https://strftime.net or man strftime
type: string default: %H:%M
- dateformat
khal will display and understand all dates in this format, see timeformat for the format
type: string default: %d.%m.
- firstweekday
the day first day of the week, were Monday is 0 and Sunday is 6
type: integer, allowed values are between 0 and 6 default: 0
The [default] section¶
The default section begins with a [default] tag. Some default values and behaviours are set here.
- debug
whether to print debugging information or not
type: boolean default: False
- default_calendar
the calendar to use if no one is specified but only one can be used (e.g. if adding a new event), this should be a valid calendar name.
type: string default: None
- default_command
command to be executed if no command is given when executing khal this is a rather important subcommand
type: option, allowed values are calendar, agenda and interactive default: calendar
A minimal sample configuration could look like this:
Example¶
[calendars]
[[home]]
path = ~/.calendars/home/
[[work]]
path = ~/.calendars/work/
[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
syncing¶
To get khal working with CalDAV you will first need to setup vdirsyncer. After each start khal will automatically check if anything has changed and automatically update its caching db (this may take some time after the initial sync, especially for large calendar collections). Therefore you might want to execute khal automatically after syncing with vdirsyncer (e.g. via cron).
Usage¶
Khal offers a set of commands, namely calendar, agenda, new, printcalendars, and interactive. See below for a description of what each of these commands does. Calling khal without any command will invoke the default command, which can be specified in the config file.
Options¶
khal (without any commands) has some options to print some information about khal:
- --version¶
Prints khal’s version number and exits
- -h, --help¶
Prints a summary of khal’s options and commands and then exits
Several options are common to almost all of khal‘s commands (exceptions are described below):
- -v¶
Be more verbose (e.g. print debugging information)
- -c CONFIGFILE¶
Use an alternate configuration file
- -a CALENDAR¶
Specify a calendar to use (which must be configured in the configuration file), can be used several times. Calendars not specified will be disregarded for this run.
- -d CALENDAR¶
Specifiy a calendar which will be disregarded for this run, can be used several times.
Commands¶
agenda¶
shows all events scheduled for given dates. khal agenda should understand the following syntax:
khal agenda [-a CALENDAR ... | -d CALENDAR ...] [--days N] [DATE ...]
If no dates are supplied as arguments, today and tomorrow are used. Dates must be given in the format specified in khal’s config file as dateformat or longdateformat. If dateformat is used, the current year is implied.
- --days N¶
Specify how many days’ (following each DATE) events should be shown.
calendar¶
shows a calendar (similiar to cal(1)) and agenda. khal calendar should understand the following syntax:
khal calendar [-a CALENDAR ... | -d CALENDAR ...] [--days N] [DATE ...]
Date selection works exactly as for khal agenda. The displayed calendar contains three consecutive months, where the first month is the month containing the first given date. If today is included, it is highlighted. Have a look at khal agenda for a descrption of the options.
interactive¶
invokes the interactive version of khal, can also be invoked by calling ikhal.
Use the arrow keys to navigate in the calendar. Press ‘tab’ or ‘enter’ to move the focus into the events column and ‘left arrow’ to return the focus to the calendar area. You can navigate the events column with the up and down arrows and view an event via pressing ‘enter’. Pressing ‘d’ will delete an event (a ‘D’ will appear in front of the events description, or ‘RO’ if you cannot delete that event). Pressing ‘d’ again will undelete that event.
When viewing an event’s details, pressing ‘enter’ again will open the currently selected event in a simple event editor; you can navigate with the arrow keys again. As long as the event has not been edited you can leave the editor with pressing ‘escape’. Once it has been edited you need to move down the ‘Cancel’ button and press the ‘enter’ key to discard your edits or press the ‘Save’ button to save your edits (and upload them on the next sync).
While the calendar area is focused, pressing ‘n’ will add a new event on the currently selected date.
new¶
allows for quick adding of new events. khal new should understand the following syntax:
khal new [-a CALENDAR] startdatetime [enddatetime] summary [description]
where start- and enddatetime are either datetimes or times in the formats defined in the config file. If no calendar is given via -a, the default calendar is used. new does no support -d and also -a may only be used once.
Start- and enddatetime can be one of the following:
- datetime datetime: start and end datetime specified, if no year is given (like the non-long version of dateformat, see config file, should allow), this year is used.
- datetime time: end date will be same as start date, unless that would make the event end before it has started, then the next day is used as end date
- datetime: event will last for defaulttime
- time time: event starting today at the first time and ending today at the second time, unless that would make the event end before it has started, then the next day is used as end date
- time: event starting today at time, lasting for the default length
- date date: all day event starting on the first and ending on the last event
- date: all day event starting at given date and lasting for default length
description is a string started by :: (which will be removed) and will be used as the new event’s description, i.d., the body of the event.
At the moment default length is either 1 hour or 1 day (should be configurable soon, too).
Some examples:
khal new 18:00 Awesome Event
adds a new event starting today at 18:00 with summary ‘awesome event’ (lasting for the default time of one hour) to the default calendar
khal new 25.10. 16:00 18:00 Another Event :: with Alice and Bob
adds a new event on 25th of October lasting from 16:00 to 18:00 with an additional description
khal new -a work 26.07. Great Event
adds a new all day event on 26th of July to the calendar work.
printcalendars¶
prints a list of all configured calendars.
Notes on Standard Compliance¶
khal tries to follow standards and RFCs (most importantly RFC 5545 iCalendar) whereever possible. Known intentional and unintentional deviations are listed below.
Events with neither END nor DURATION¶
- While the RFC states
- A calendar entry with a “DTSTART” property but no “DTEND” property does not take up any time. It is intended to represent an event that is associated with a given calendar date and time of day, such as an anniversary. Since the event does not take up any time, it MUST NOT be used to record busy time no matter what the value for the “TRANSP” property.
khal transforms those events into all-day events lasting for one day (the start date). As long a those events do not get edited, these changes will not be written to the vdir (and with that to the CalDAV server). Any timezone information that was associated with the start date gets discarded.
Note
While the main rationale for this behaviour was laziness on part of the main author of khal, other calendar software shows the same behaviour (e.g. Google Calendar and Evolution).
Timezones¶
Getting localized time right, seems to be the most difficult part about calendaring (and messing it up ends in missing the one imported meeting of the week). So I’ll briefly describe here, how khal tries to handle timezone information, which information it can handle and which it can’t.
All datetimes are saved to the local database as UTC Time. Datetimes that are already UTC Time, e.g. 19980119T070000Z are saved as such. Datetimes in local time and with a time zone reference that khal can understand (Olson database) are converted to UTC and than saved, e.g. TZID=America/New_York:19980119T020000. Floating times, e.g. 19980118T230000 (datetimes which are neither UTC nor have a timezone specified) are treated as if the default timezone (specified in khal’s config file) was specified. Datetimes with a specified timezone that khal does not understand are treated as if they were floating time.
khal expects you want all start and end dates displayed in local time (which can be configured in the config file).
VTIMEZONE components of calendars are totally ignored at the moment, as are daylight saving times, instead it assumes that the TZID of DTSTART and DTEND properties are valid OlsonDB values, e.g. America/New_York (seems to be the default for at least the calendar applications I tend to use).
To summarize: as long as you are always in the same timezone and your calendar is, too, khal probably shows the right start and end times. Otherwise: Good Luck!
Seriously: be careful when changing timezones and do check if khal shows the correct times anyway (and please report back if it doesn’t).
Feedback and Contributing to khal¶
The prefered way of interaction with khal‘s developer is via github. But if you do not feel comfortable using github, please don’t hesitate to contact me via email (khal at lostpackets dot de) or via jabber/XMPP (geier at jabber dot ccc dot de).
Feedback¶
Please do provide feedback if khal works for you or even more importantly if it doesn’t. Feature requests and other ideas on how to improve khal are also welcome.
Submitting a Bug¶
If you found a bug or any part of khal isn’t working as you expected, please check if that bug is either already reported at
https://github.com/geier/khal/issues?state=open
If it isn’t, always run the command again with the -v option and paste the output of that (of course you can edit out any private details like your username and resource).
Hacking¶
If you want to hack on khal and have some questions, please don’t hesitate to contact me, I will gladly provide you with any information you need. If you want to implement some larger features, it’s probably best to contact me first and see if me or somebody else is already working on it.
Before submitting your first patch, please add yourself to CONTRIBUTORS.txt.
You can submit patches either via github pull requests (the prefered method) or via email (khal at lostpackets dot de).
Changelog¶
All notable changes to this project should be documented here. For more detailed information have a look at the git log.
0.3.0¶
released on 2014-09-03
- new unified documentation
- html documentation (website) and man pages are all generated from the same sources via sphinx (type make html or make man in doc/, the result will be build in build/html or build/man respectively
- the new documentation lives in doc/
- the package sphinxcontrib-newsfeed is needed for generating the html version (for generating an RSS feed)
- the man pages live doc/build/man/, they can be build by running make man in doc/sphinx/
new dependencies: configobj, tzlocal>=1.0
IMPORTANT: the configuration file’s syntax changed (again), have a look at the new documentation for details
local_timezone and default_timezone will now be set to the timezone the computer is set to (if they are not set in the configuration file)
Frequently Asked Questions (FAQ)¶
- start up of khal and ikhal is very slow
In some case the pytz (python timezone) is only available as a zip file, as pytz accesses several parts during initialization this takes some time. If time python -c “import pytz; pytz.timezone(‘Europe/Berlin’)” takes nearly as much time as running khal, uncompressing that file via pytz via (sudo) pip unzip pytz might help.
- ikhal raises an Exception: AttributeError: ‘module’ object has no attribute ‘SimpleFocusListWalker’
You probably need to upgrade urwid to version 1.1.0, if your OS does come with an older version of urwid you can install the latest version to userspace (with out messing up your default installation) with pip install –upgrade urwid –user.
- Installation stops with an error: source/str_util.c:25:20: fatal error: Python.h: No such file or directory
You do not have the Python development headers installed, on Debian based Distributions you can install them via aptitude install python-dev.
License¶
khal is released under the Expat/MIT License:
Copyright (c) 2013-2014 Christian Geier et al.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
News¶
Below is a list of new releases and other khal related news. Both is also
available as an rss feed .
khal v0.3 released¶
A new release of khal is here: khal v0.3.0 (also available on pypi).
If you want to update your installation from pypi, you can run sudo pip install –upgrade khal.
CHANGELOG¶
- new unified documentation
- html documentation (website) and man pages are all generated from the same sources via sphinx (type make html or make man in doc/, the result will be build in build/html or build/man respectively (also available on Read the Docs)
- the new documentation lives in doc/
- the package sphinxcontrib-newsfeed is needed for generating the html version (for generating an RSS feed)
- the man pages live doc/build/man/, they can be build by running make man in doc/sphinx/
new dependencies: configobj, tzlocal>=1.0
IMPORTANT: the configuration file’s syntax changed (again), have a look at the new documentation for details
local_timezone and default_timezone will now be set to the timezone the computer is set to (if they are not set in the configuration file)
khal v0.2 released¶
A new release of khal is here: khal v0.2.0 (also available on pypi).
If you want to update your installation from pypi, you can run sudo pip install –upgrade khal.
From now on khal relies on vdirsyncer for CalDAV sync. While this makes khal a bit more complicated to setup, vdirsyncer is much better tested than khal and also the bus factor increased (at least for parts of the project).
You might want to head over to the tutorial on how to setup vdirsyncer. Afterwards you will need to re-setup your khal configuration (copy the new example config file), also you will need to delete your old (local) database, so please make sure you did sync everything.
Also khal‘s command line syntax changed qutie a bit, so you might want to head over the documentation.
khal v0.1.1 released¶
A small bugfix release: khal v0.1.0 Example config file now in source dist.
khal v0.1 released¶
The first release of khal is here: khal v0.1.0 (and also available on pypi now).
The next release, hopefully coming rather sooner than later, will get rid of its own CalDAV implementation, but instead use vdirsyncer; you can already try it out via checking out the branch vdir at github.
pycarddav and khal at 30c3¶
If you will be 30C3 and would like to discuss the faults and merits of khal or pycarddav, commandline calendaring/addressbooking in general, your ideas or just have a beer or mate, I’d love to meet up. You can find my contact details under Feedback.
Call for Testing¶
While there isn’t a release yet, khal is, at least partly, in a usable shape by now. Please report any errors you stumble upon and improvement suggestions you have either via email or github (if you don’t have any privacy concerns etc. I’d prefer you use github since it is public, but I’ll soon set up a mailing list). TODO.rst gives you an idea about the plans I currently have for khal‘s near future.
khal v0.3 released¶
A new release of khal is here: khal v0.3.0 (also available on pypi).
If you want to update your installation from pypi, you can run sudo pip install –upgrade khal.
CHANGELOG¶
- new unified documentation
- html documentation (website) and man pages are all generated from the same sources via sphinx (type make html or make man in doc/, the result will be build in build/html or build/man respectively (also available on Read the Docs)
- the new documentation lives in doc/
- the package sphinxcontrib-newsfeed is needed for generating the html version (for generating an RSS feed)
- the man pages live doc/build/man/, they can be build by running make man in doc/sphinx/
new dependencies: configobj, tzlocal>=1.0
IMPORTANT: the configuration file’s syntax changed (again), have a look at the new documentation for details
local_timezone and default_timezone will now be set to the timezone the computer is set to (if they are not set in the configuration file)
khal v0.2 released¶
A new release of khal is here: khal v0.2.0 (also available on pypi).
If you want to update your installation from pypi, you can run sudo pip install –upgrade khal.
From now on khal relies on vdirsyncer for CalDAV sync. While this makes khal a bit more complicated to setup, vdirsyncer is much better tested than khal and also the bus factor increased (at least for parts of the project).
You might want to head over to the tutorial on how to setup vdirsyncer. Afterwards you will need to re-setup your khal configuration (copy the new example config file), also you will need to delete your old (local) database, so please make sure you did sync everything.
Also khal‘s command line syntax changed qutie a bit, so you might want to head over the documentation.
khal v0.1.1 released¶
A small bugfix release: khal v0.1.0 Example config file now in source dist.
khal v0.1 released¶
The first release of khal is here: khal v0.1.0 (and also available on pypi now).
The next release, hopefully coming rather sooner than later, will get rid of its own CalDAV implementation, but instead use vdirsyncer; you can already try it out via checking out the branch vdir at github.
pycarddav and khal at 30c3¶
If you will be 30C3 and would like to discuss the faults and merits of khal or pycarddav, commandline calendaring/addressbooking in general, your ideas or just have a beer or mate, I’d love to meet up. You can find my contact details under Feedback.
Call for Testing¶
While there isn’t a release yet, khal is, at least partly, in a usable shape by now. Please report any errors you stumble upon and improvement suggestions you have either via email or github (if you don’t have any privacy concerns etc. I’d prefer you use github since it is public, but I’ll soon set up a mailing list). TODO.rst gives you an idea about the plans I currently have for khal‘s near future.