CalDAV Calendar — CalDAV 日历同步
v1.0.1使用 vdirsyncer + khal 同步和查询 CalDAV 日历(iCloud、Google、Fastmail、Nextcloud 等)。适用于 Linux。
运行时依赖
安装命令
点击复制本土化适配说明
CalDAV Calendar — CalDAV 日历同步 安装说明: 安装命令:["openclaw skills install caldav-calendar"] 支持国内镜像加速,使用 --registry https://cn.longxiaskill.com 参数可加速下载
技能文档
CalDAV Calendar(vdirsyncer + khal)
vdirsyncer 将 CalDAV 日历同步到本地 .ics 文件。khal 用于读取和写入日历。
首先同步
在查询之前或进行更改后,务必先同步:
vdirsyncer sync
查看事件
khal list # 今天
khal list today 7d # 未来7天
khal list tomorrow # 明天
khal list 2026-01-15 2026-01-20 # 日期范围
khal list -a Work today # 特定日历
搜索
khal search "meeting"
khal search "dentist" --format "{start-date} {title}"
创建事件
khal new 2026-01-15 10:00 11:00 "会议标题"
khal new 2026-01-15 "全天事件"
khal new tomorrow 14:00 15:30 "电话" -a Work
khal new 2026-01-15 10:00 11:00 "带备注" :: 这里是描述
创建后,同步以推送更改:
vdirsyncer sync
编辑事件(交互式)
khal edit 是交互式的 — 需要 TTY。如果自动化,请使用 tmux:
khal edit "搜索词"
khal edit -a 日历名称 "搜索词"
khal edit --show-past "旧事件"
菜单选项:
- s → 编辑摘要
- d → 编辑描述
- t → 编辑日期时间范围
- l → 编辑位置
- D → 删除事件
- n → 跳过(保存更改,下一个匹配)
- q → 退出
编辑后,同步:
vdirsyncer sync
删除事件
使用 khal edit,然后按 D 删除。
输出格式
用于脚本:
khal list --format "{start-date} {start-time}-{end-time} {title}" today 7d
khal list --format "{uid} | {title} | {calendar}" today
占位符:{title}、{description}、{start}、{end}、{start-date}、{start-time}、{end-date}、{end-time}、{location}、{calendar}、{uid}
缓存
khal 在 ~/.local/share/khal/khal.db 缓存事件。如果同步后数据看起来过时:
rm ~/.local/share/khal/khal.db
初始设置
1. 配置 vdirsyncer(~/.config/vdirsyncer/config)
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"