Khal - vdirsyncer

Sync remote calendar

Vdirsyncer is a command-line tool for synchronizing calendars and addressbooks between a variety of servers and the local filesystem.

Topic

Installation

1. Install synchronize with Remote/Cloud calendar

pip3 install --upgrade-strategy eager vdirsyncer

Google Calendar

Google API Manger

1. Create new project in Google API Manager

  1. Google Api Manager

    • Project Name: {NAME}-{NUMBER}
    • Location: Optional
    • Click Create

    new project in google api manager

  2. API and Service Home Page

    api and service homepage

  3. Click + ENABLE APIS AND SERVICE

    enable apis and service

2. Enable CalDav API for google calendar API access

  1. API Library homepage

    API library homepage

  2. Search CalDav API

    search caldav api

  3. Click to enable CalDav API

    click to enable

  4. Success enable CalDav API

    enabled CalDav API

3. Enable Authorize Credentials

  1. Click left side-bar Credentials

    click credentials

  2. Click + CREATE CREDENTIALS and + OAuth client ID

    create oauth client id

  3. Click CONFIGURE CONSENT SCREEN

    configure consent screen

  4. Create OAuth consent screen with External and click CREATE

    create oauth consent screen

    1. Edit app registration
      • App Name: required
      • User Email: required
      • Develops Email: required

    edit app registration

    1. Scopes
      • click Save and Confirm

    edit app scopes

    1. Test Users
      • click Save and Confirm

    edit app testusers

    1. Summary

    edit app summary

4. Enable Web Application

  1. Click left side-bar Credentials

    click credentials

  2. Click + CREATE CREDENTIALS and OAuth client ID then select Web Application

    select oauth client id web application

  3. Create Web Application

    redirect URLs: http://127.0.0.1 1

    create web application

  4. Created OAuth Client for Web application

    Client ID + Client secret

    created oauth client for web application

Configuration

1. Create vdirsyncer configuration file

mkdir -p ~/.config/vdirsyncer
touch ~/.config/vdirsyncer/config

2. Copy the contents below into configuration file

  • client_id and client_secret is created from OAuth Client for Web Application

created oauth client for web application

cat <<-EOF > ~/.config/vdirsyncer/config
[general]
status_path = "~/.calendars/status"

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

[storage personal]
type = "google_calendar"
token_file = "~/.vdirsyncer/google_calendar_token"
client_id = "241086233307-rdb38l3lfa7bjlfetgsg0lg2bp47hgmc.apps.googleusercontent.com"
client_secret = "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"

[storage personallocal]
type = "filesystem"
path = "~/.calendars/"
fileext = ".ics"
EOF

vdirsyncer/config

3. Discover google calendar via CalDav APIs

  • personal_sync is discover pair, please refer in configuration file above.
vdirsyncer discover personal_sync

4. Select google account

select google account

  • click Advanced and click Go to <api name> (unsafe)

    continue with unsafe

  • Continue access calendar with APIs

    continue access with api

  • Success obtained token

    success obtained token

5. Sync Google Calendar

vdirsyncer sync

6. add category for each imported contents

  • append into ~/.config/khal/config depending on contents of ~/.calendars/
[[ ${NAME} ]]
path = "~/.calendars/${content_file}"
color = blue
1

http://127.0.0.1: redirect url will discover by vdirsyncer with random port number