Logseq Caldev is a tool to generate CalDAV Tasks and Calendar events from Logseq Tasks using Logseq's HTTP API.
The tool generates iCalendar ics files in a directory, which can then be synced to CalDAV using tools like vdirsyncer.
Two-way sync is not currently supported, any modifications made to the specified CalDAV endpoints via other apps will be overridden whenever the sync is run.
- a CalDAV server
- an accessible Logseq HTTP API endpoint
- a tool which can sync a directory of
.icsfiles to a CalDAV server
- Nextcloud Calendar (created with task support)
- vdirsyncer
A fully functional sync requires a few services to be setup.
Open Logseq and enable the HTTP API Endpoint.
Setup an Authorized Token, copy the token name and password for later use.
Go to the Nextcloud Calendar app and create a Calendar with tasks support (New calendar with tasks list).
You may want to also want to create a Nextcloud App Password for vdirsyncer usage via the WebUI under (Settings -> Security -> Devices & Sessions -> App Name/Password).
Create a vdirsyncer config at ~/.config/vdirsyncer/config like:
[general]
status_path = "~/.local/state/vdirsyncer"
[pair nextcloud_calendars]
a = "nextcloud_calendars_local"
b = "nextcloud_calendars_remote"
collections = ["from a", "from b"]
metadata = ["color"]
conflict_resolution = "a wins"
[storage nextcloud_calendars_local]
type = "filesystem"
path = "~/.local/state/calendars/nextcloud/"
fileext = ".ics"
[storage nextcloud_calendars_remote]
type = "caldav"
url = "https://nextcloud.mydomain.com/remote.php/caldav/"
username = "myuser"
password = "XXXX-XXXX-XXXX"Discover Calendars
vdirsyncer discover nextcloud_calendarsThis will create the needed directories at ~/.local/state/calendars/nextcloud (or otherwise specified in your local calendar storage).
There are two environment variables required to run the sync:
export LSQ_HTTP_BASIC_AUTH = "myLogseqAuthorizationToken"
export LSQ_TASK_DIR = "~/.local/state/calendars/nextcloud/logseq"
export LSQ_EVENT_DIR = "~/.local/state/calendars/nextcloud/logseq" # this is LSQ_TASK_DIR if not setTo parse logseq tasks and write to the event/task directories:
# run with nix
nix run github:kraftnix/logseq-caldav
# or add to shell
nix shell github:kraftnix/logseq-caldav
logseq-caldav
# or from root of repo
nu logseq-caldav.nuOptionally run a vdirsyncer sync:
export LSQ_VDIRSYNCER_CALENDAR = "nextcloud_calendars/logseq"
logseq-caldav --syncYou can make the script run periodically:
logseq-caldav --sync --period 30min- Davx5 on Android should set the logseq calendar to readonly to reduce churn of events/tasks (rewriting of PRODID in tasks)
- Task and Event titles and descriptions (at least in testing with Nextcloud Calendar + vdirsyncer) seem to sanitise the input:
- ids like
((60def7c5-9561-5ec4-b17b-e74c091df1d7))are transformed to60def7c5 9561 5ec4 b17b e74c091df1d7 - pages/tags like
[[MyPage]]are transformed toMyPage
- ids like
- All CalDAV events generated via the
parse_tasks.nuscript are overwritten on each use, so your CalDAV sync tool (like vdirsyncer) must either overwrite external changes or you must handle the sync conflicts yourself. - The script will not perform any writes on
.icsfiles which have not changed (theLast-Modifiedfield in VTODO is not checked when performing the equality check) - The tool makes a best attempt to split multiline Logseq tasks into a separate Summary and Description, where the Summary is the first line (without LATER/DONE) and the description is any other line afterwards.
- Using a CalDAV server without support for combined Calendars and Tasks is supported, but you must choose two separate directories
(and therefore calendars) to sync the ics files to, by default
LSQ_EVENT_DIRuses the same value asLSQ_TASK_DIR, this is an assumption that the same CalDAV directory can be used for both tasks (VTODO) and calendar events (VEVENT). - VTODO events which have a DUE (deadline) earlier than a DTSTAMP (scheduled) are invalid, so we skip writing the deadline to the event.
- Logseq sometimes changed the UUID of an already existing/parsed task, in order to clean orphaned tasks/events when this happens, we must check for non-matching events in the Task / Event directories.
- passthrough A/B/C logseq priority to vtodo priority
- consider adding events for Scheduled/Deadline
- all datetimes are your current timezone at the moment