简介
基于成熟开源方案 vdirsyncer 与 khal,为 Linux 用户提供 iCloud、Google 等 CalDAV 日历的本地同步与高效查询能力,实现离线日程管理。
原始描述
Sync and query CalDAV calendars (iCloud, Google, Fastmail, Nextcloud, etc.) using vdirsyncer + khal. Works on Linux.
通过你的 Agent 添加
安装目录:caldav-calendar/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
caldav-calendar 技能基于 vdirsyncer 和 khal 两大开源工具,为 Linux 用户提供完整的 CalDAV 日历管理方案。核心工作流分为同步与查询两个阶段:通过 vdirsyncer sync 将 iCloud、Google Calendar、Fastmail、Nextcloud 等远程日历同步至本地 .ics 文件,再使用 khal 命令进行离线查询和管理。支持查看日程列表(khal list)、搜索事件(khal search)、创建新事件(khal new)以及交互式编辑(khal edit)。用户可通过自定义输出格式(--format)获取结构化数据,便于脚本集成。
显著优点
该方案的最大优势在于离线可用性与数据主权。同步后所有日历数据存储在本地,无需网络即可极速查询。支持多平台 CalDAV 服务统一接入,实现跨生态日程整合。命令行界面响应迅速,配合自定义格式模板,可轻松与 awk、grep 等工具链集成,适合自动化工作流。相比图形界面,资源占用极低,且所有数据保留在本地文件系统,隐私可控。
潜在缺点与局限性
主要限制在于平台绑定:仅支持 Linux 系统,Windows 和 macOS 用户无法直接使用。配置门槛较高,用户需手动编辑 vdirsyncer 和 khal 的配置文件(INI 格式),理解 CalDAV URL 结构和凭据存储方式。交互式编辑(khal edit)需要 TTY 环境,自动化场景需借助 tmux 等工具。此外,作为文档型技能,实际功能完全依赖外部二进制程序,若 vdirsyncer 或 khal 未安装或版本不兼容,功能将完全失效。
适合的目标群体
该技能最适合熟悉 Linux 命令行环境的开发者、系统管理员及技术型用户。特别是需要在工作流中集成日历数据的用户(如通过脚本生成日报、自动检查会议冲突),以及重视数据隐私、希望避免将日历数据托管在云端浏览器的用户。对于使用多平台日历服务(如同时使用 iCloud 和 Google Calendar)需要统一视图的用户,此工具提供了高效的聚合方案。
使用风险
常规风险主要包括配置复杂度和依赖维护。CalDAV 凭据配置不当(如明文存储密码文件权限过于开放)可能导致泄露风险,建议将密码文件设置为 600 权限并使用 password.fetch 机制。依赖项 vdirsyncer 和 khal 虽为成熟项目,但若发行版仓库版本滞后,可能出现兼容性问题。缓存文件(~/.local/share/khal/khal.db)损坏可能导致数据展示异常,需手动清理重建。此外,命令行操作缺乏图形界面的防误删机制,使用 khal edit 删除事件(按 D 键)操作不可逆,需谨慎确认。
技能正文
name: caldav-calendar
description: Sync and query CalDAV calendars (iCloud, Google, Fastmail, Nextcloud, etc.) using vdirsyncer + khal. Works on Linux.
metadata: {"clawdbot":{"emoji":"📅","os":["linux"],"requires":{"bins":["vdirsyncer","khal"]},"install":[{"id":"apt","kind":"apt","packages":["vdirsyncer","khal"],"bins":["vdirsyncer","khal"],"label":"Install vdirsyncer + khal via apt"}]}}
CalDAV Calendar (vdirsyncer + khal)
vdirsyncer syncs CalDAV calendars to local .ics files. khal reads and writes them.
Sync First
Always sync before querying or after making changes:
vdirsyncer sync
View Events
khal list # Today
khal list today 7d # Next 7 days
khal list tomorrow # Tomorrow
khal list 2026-01-15 2026-01-20 # Date range
khal list -a Work today # Specific calendar
Search
khal search "meeting"
khal search "dentist" --format "{start-date} {title}"
Create Events
khal new 2026-01-15 10:00 11:00 "Meeting title"
khal new 2026-01-15 "All day event"
khal new tomorrow 14:00 15:30 "Call" -a Work
khal new 2026-01-15 10:00 11:00 "With notes" :: Description goes here
khal list # Today
khal list today 7d # Next 7 days
khal list tomorrow # Tomorrow
khal list 2026-01-15 2026-01-20 # Date range
khal list -a Work today # Specific calendar
khal search "meeting"
khal search "dentist" --format "{start-date} {title}"
Create Events
khal new 2026-01-15 10:00 11:00 "Meeting title"
khal new 2026-01-15 "All day event"
khal new tomorrow 14:00 15:30 "Call" -a Work
khal new 2026-01-15 10:00 11:00 "With notes" :: Description goes here
khal new 2026-01-15 10:00 11:00 "Meeting title"
khal new 2026-01-15 "All day event"
khal new tomorrow 14:00 15:30 "Call" -a Work
khal new 2026-01-15 10:00 11:00 "With notes" :: Description goes here
After creating, sync to push changes:
vdirsyncer sync
Edit Events (interactive)
khal edit is interactive — requires a TTY. Use tmux if automating:
khal edit "search term"
khal edit -a CalendarName "search term"
khal edit --show-past "old event"
Menu options:
s→ edit summaryd→ edit descriptiont→ edit datetime rangel→ edit locationD→ delete eventn→ skip (save changes, next match)q→ quit
After editing, sync:
vdirsyncer sync
Delete Events
Use khal edit, then press D to delete.
Output Formats
For scripting:
khal list --format "{start-date} {start-time}-{end-time} {title}" today 7d
khal list --format "{uid} | {title} | {calendar}" today
Placeholders: {title}, {description}, {start}, {end}, {start-date}, {start-time}, {end-date}, {end-time}, {location}, {calendar}, {uid}
Caching
khal caches events in ~/.local/share/khal/khal.db. If data looks stale after syncing:
rm ~/.local/share/khal/khal.db
Initial Setup
1. Configure vdirsyncer (~/.config/vdirsyncer/config)
~/.config/vdirsyncer/config)Example for iCloud:
[general]
status_path = "~/.local/share/vdirsyncer/status/"
[pair icloud_calendar]
a = "icloud_remote"
b = "icloud_local"
collections = ["from a", "from b"]
conflict_resolution = "a wins"
[storage icloud_remote]
type = "caldav"
url = "https://caldav.icloud.com/"
username = "your@icloud.com"
password.fetch = ["command", "cat", "~/.config/vdirsyncer/icloud_password"]
[storage icloud_local]
type = "filesystem"
path = "~/.local/share/vdirsyncer/calendars/"
fileext = ".ics"
Provider URLs:
- iCloud:
https://caldav.icloud.com/ - Google: Use
google_calendarstorage type - Fastmail:
https://caldav.fastmail.com/dav/calendars/user/EMAIL/ - Nextcloud:
https://YOUR.CLOUD/remote.php/dav/calendars/USERNAME/
2. Configure khal (~/.config/khal/config)
[calendars]
[[my_calendars]]
path = ~/.local/share/vdirsyncer/calendars/*
type = discover
[default]
default_calendar = Home
highlight_event_days = True
[locale]
timeformat = %H:%M
dateformat = %Y-%m-%d
3. Discover and sync
vdirsyncer discover # First time only
vdirsyncer sync
[calendars]
[[my_calendars]]
path = ~/.local/share/vdirsyncer/calendars/*
type = discover
[default]
default_calendar = Home
highlight_event_days = True
[locale]
timeformat = %H:%M
dateformat = %Y-%m-%d
vdirsyncer discover # First time only
vdirsyncer sync
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。