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
sections | sub-sections | |
---|---|---|
1 | Installation | |
2 | Google Calendar | APIs manager |
Configuration |
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
-
- Project Name: {NAME}-{NUMBER}
- Location: Optional
- Click Create
-
API and Service Home Page
-
Click + ENABLE APIS AND SERVICE
2. Enable CalDav API for google calendar API access
-
API Library homepage
-
Search CalDav API
-
Click to enable CalDav API
-
Success enable CalDav API
3. Enable Authorize Credentials
-
Click left side-bar Credentials
-
Click + CREATE CREDENTIALS and + OAuth client ID
-
Click CONFIGURE CONSENT SCREEN
-
Create OAuth consent screen with External and click CREATE
- Edit app registration
- App Name: required
- User Email: required
- Develops Email: required
- Scopes
- click Save and Confirm
- Test Users
- click Save and Confirm
- Summary
- Edit app registration
4. Enable Web Application
-
Click left side-bar Credentials
-
Click + CREATE CREDENTIALS and OAuth client ID then select Web Application
-
Create Web Application
redirect URLs:
http://127.0.0.1
1 -
Created OAuth Client for Web application
Client ID
+Client secret
Configuration
1. Create vdirsyncer configuration file
mkdir -p ~/.config/vdirsyncer
touch ~/.config/vdirsyncer/config
2. Copy the contents below into configuration file
client_id
andclient_secret
is created from 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
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
-
click Advanced and click Go to <api name> (unsafe)
-
Continue access calendar with APIs
-
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
http://127.0.0.1: redirect url will discover by vdirsyncer with random port number