关于 caldav-calendar
此技能使用 vdirsyncer 同步 CalDAV 日历文件,并通过 khal 查看和更改事件,适用于命令行日历管理、搜索、编辑及脚本化输出。
主要功能
- 01将 CalDAV 日历同步到本地 .ics 文件
- 02按日期范围或日历列出事件
- 03搜索事件并自定义输出字段
- 04创建、编辑和删除事件
- 05按适合脚本的格式输出事件列表
适用场景
- 01查看指定日期范围内的日程
- 02通过文本查找会议
- 03添加或更新日历事件并同步更改
- 04以便于脚本处理的格式导出事件详情
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ sundial-org/ awesome-openclaw-skills --skill caldav-calendar安装后在 Claude Code 中输入/caldav-calendar确认已加载。
详细介绍
CalDAV 日历(vdirsyncer + khal)
vdirsyncer 将 CalDAV 日历同步到本地 .ics 文件。khal 用于读取和写入这些文件。
先同步
查询日历或更改日历后,务必先进行同步:
vdirsyncer sync
查看事件
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}"
创建事件
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
创建后进行同步以推送更改:
vdirsyncer sync
编辑事件(交互式)
khal edit 是交互式命令,需要 TTY。自动化时请使用 tmux:
khal edit "search term"
khal edit -a CalendarName "search term"
khal edit --show-past "old event"
菜单选项:
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"
url = "https://caldav.icloud.com/"
username = "[email protected]"
password.fetch = ["command", "cat", "~/.config/vdirsyncer/icloud_password"]
[storage icloud_local]
type = "filesystem"
path = "~/.local/share/vdirsyncer/calendars/"
fileext = ".ics"
服务商 URL:
- iCloud:
https://caldav.icloud.com/ - Google:使用
google_calendar存储类型 - Fastmail:
https://caldav.fastmail.com/dav/calendars/user/EMAIL/ - Nextcloud:
https://YOUR.CLOUD/remote.php/dav/calendars/USERNAME/
2. 配置 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. 发现并同步
vdirsyncer discover # First time only
vdirsyncer sync
评论
支持 Markdown