Science and technology

Organize and sync your calendar with khal and vdirsyncer

Last yr, I introduced you 19 days of recent (to you) productiveness instruments for 2019. This yr, I am taking a unique method: constructing an atmosphere that can help you be extra productive within the new yr, utilizing instruments you could or might not already be utilizing.

Keep observe of your schedule with khal and vdirsyncer

Calendars are a ache to cope with, and discovering good tooling is all the time onerous. But I’ve made some progress since final yr after I listed calendaring as one of my “fails.”

The most tough factor about calendars at the moment is that now they virtually all the time must be shared on-line indirectly. The two hottest on-line calendars are Google Calendar and Microsoft Outlook/Exchange. Both are used closely in company environments, which suggests my calendar has to assist one or each choices.

Khal is a console-based calendar that reads and writes VCalendar recordsdata. It’s pretty simple to configure, however it doesn’t assist syncing with different purposes.

Fortunately, khal works with vdirsyncer, a nifty command-line program that may synchronize on-line calendars (and contacts, which I will speak about in a separate article) to your native drive. And sure, this contains importing new occasions, too.

Vdirsyncer is a Python three program, and it may be put in through your package deal supervisor or pip. It can synchronize CalDAV, VCalendar/iCalendar, Google Calendar, and native recordsdata in a listing. Since I exploit Google Calendar, I will use that for instance, though it isn’t the simplest factor to arrange.

Setting vdirsyncer up for Google is well-documented, so I will not go into the nuts and bolts right here. The vital factor is to ensure your sync pairs are arrange in a means that units Google Calendar because the “winner” for battle decision. That is, if there are two updates to the identical occasion, it must know which one takes priority. Do so with one thing like this:

[general]
status_path = "~/.calendars/status"

[pair personal_sync]
a = "personal"
b = "personallocal"
collections = ["from a", "from b"]
conflict_resolution = "a wins"
metadata = ["color"]

[storage personal]
kind = "google_calendar"
token_file = "~/.vdirsyncer/google_calendar_token"
client_id = "google_client_id"
client_secret = "google_client_secret"

[storage personallocal]
kind = "filesystem"
path = "~/.calendars/Personal"
fileext = ".ics"

After the primary sync of vdirsyncer, you’ll find yourself with a collection of directories within the storage path. Each will include a number of recordsdata, one for every entry within the calendar. The subsequent step is to get them into khal. Start by operating khal configure to do the preliminary setup.

Now, operating khal interactive will carry up the show proven at the start of this text. Typing n will carry up the New Event dialog. One small factor to notice right here: the calendars are named to match the directories that vdirsyncer creates, however you possibly can change the khal config file to present them clearer names. Adding colours to entries based mostly on which calendar they’re on can even assist you to establish which is which on the checklist:

[calendars]
[[personal]]
path = ~/.calendars/Personal/[email protected]/
coloration = mild magenta
[[holidays]]
path = ~/.calendars/Personal/cln2stbjc4hmgrrcd5i62ua0ctp6utbg5pr2sor1dhimsp31e8n6errfctm6abj3dtmg@digital/
coloration = mild blue
[[birthdays]]
path = ~/.calendars/Personal/c5i68sj5edpm4rrfdchm6rreehgm6t3j81jn4rrle0n7cbj3c5m6arj4c5p2sprfdtjmop9ecdnmq@digital/
coloration = brown

Now whenever you run khal interactive, every calendar will likely be coloured to tell apart it from the others, and whenever you add a brand new entry, it is going to have a extra descriptive identify.

The setup is somewhat tough, however as soon as it is performed, khal with vdirsyncer provides you a straightforward technique to handle calendar occasions and preserve them in sync together with your on-line providers.

Most Popular

To Top