# Calendar and Reminders

## Calendar sources

A source with `"kind": "calendar"` reads every calendar on this Mac, the ones in Calendar's sidebar whether they're ticked or not, through macOS itself. Nothing is fetched from the internet and nothing leaves the Mac. It suits a page an agent writes for you, such as "my next meeting, with a Join button", next to everything else in the panel. [Examples/pages/calendar.json](https://legatobar.com/examples/calendar.json) is a complete page:

```json
"sources": { "calendar": { "kind": "calendar", "window": "month", "every": "5m" } },
"cards": [
  { "id": "up", "type": "countdown", "label": "Next up", "at": "2026-01-01T00:00:00Z",
    "source": { "ref": "calendar",
      "map": { "label": "up.title", "at": "up.at", "detail": "up.detail" },
      "empty": { "when": { "path": "has_up", "equals": false }, "text": "No timed events coming up" } },
    "actions": [ { "kind": "open", "label": "Join", "icon": "video.fill", "url": "{up.join}", "prominent": true,
                   "when": { "path": "up.has_join", "equals": true } } ] },
  { "id": "month", "type": "month", "days": 7, "hide_empty_days": true, "max_events": 7, "items": [],
    "source": { "ref": "calendar",
      "map": { "items": { "each": "agenda", "limit": 300, "fields": {
        "title": "title",
        "start": { "if": { "path": "all_day", "equals": true }, "then": "start_date", "else": "start" },
        "end": { "if": { "path": "all_day", "equals": true }, "then": "end_date", "else": "end" },
        "detail": "location", "url": "join", "color": "color" } } } },
    "actions": [ { "kind": "add-event", "label": "New Event", "icon": "calendar.badge.plus" } ],
    "actions_placement": "corner" }
]
```

The `month` card is a [`month`](https://legatobar.com/docs/card-time.md#month): this month as a grid, a dot in each calendar's colour on the days with events, and under it the chosen day (today until you click another) and the six after it, leaving out empty days, seven events at a time. `days` goes up to 30, to list the month ahead. `agenda` lists events in order and `limit` keeps the first so many, so size `limit` for your calendar: about 72 days are read, and a busy calendar may need up to the card's 300. The arrows beside the month's name page to other months, up to 12 either way: the source then reads that month too, so the card has its events.

Only `agenda` and `agenda_count` follow the month on screen; `up`, `next`, `today` and `events` stay with now, so a **Next up** card on the same source doesn't move.

Each row has a line at now, a **Join** button on the meeting under way, and its calendar's colour, as Calendar shows it. Change a calendar's colour in Calendar and the card follows. All-day events pass their dates (`start_date`, `end_date`) rather than moments, so they stay on their day.

For a list of the days ahead instead, use an [`agenda`](https://legatobar.com/docs/card-time.md#agenda) with `days` (up to 7) and a `window` that covers them: `"window": "3d"` with `"days": 3`, mapping `items` from `agenda` the same way.

| Field | Required? | Meaning |
| --- | --- | --- |
| `kind` | yes | `calendar`. |
| `window` | no | How far ahead to look, in hours or days from `1h` to `7d`, or `month` for a month card: the six weeks it shows, and the 30 days after them for its list (`days`). Default `2d`. |
| `calendars` | no | Calendar names to include, as Calendar shows them. Default: every calendar. |
| `every` | no | A safety refresh, default `5m`. The source also refreshes within seconds of a change in any calendar, when an event starts or ends, at midnight and when the time zone changes. |
| `derive` | no | As for any source. |

The answer, which `map` reads:

| Path | What it is |
| --- | --- |
| `up` | What the panel should show now: the event under way, else the next one. `title`, `at` (its end while under way, else its start, for a `countdown`), `detail` (how long, or "Now · until 10:45 AM", and where), `join`, `has_join`, `in_progress`, `calendar`. Null when nothing is coming. |
| `has_up` | Whether there is an `up`. |
| `next`, `current` | The next event to start, and the one under way, or null. |
| `today` | Every event today, including those already over (`past: true`). |
| `events` | What's under way or still to come within `window`. |
| `agenda` | Every event on every whole day `window` touches, including those already over: for an `agenda` or `month` card. With `"window": "2d"` at 10 AM, that's all of today, tomorrow and the day after. With `"window": "month"`, the grid's six weeks and the 30 days after them, so a month card's `days` list has its events; `events` still stops at the grid. |
| `today_count`, `agenda_count`, `busy_minutes_today`, `busy_today` | How many events today and in `agenda`, and the time booked today, with overlaps counted once (`busy_today` is formatted, such as "2h 45m"). |
| `empty` | "Nothing in the next 2 days", worded for `window` ("Nothing this month" for `month`). |

Each event has `title`, `start` and `end` (ISO 8601 with this Mac's offset), `all_day`, `time` ("9:30 AM" or "All day"), `time_range`, `day` ("Today", "Tomorrow", "Fri, Oct 30"), `location`, `join`, `has_join`, `calendar`, `color` (`#RRGGBB`), `in_progress` and `past`. All-day events also carry `start_date` and `end_date` (the last day, inclusive), since they belong to a date wherever the Mac is. Declined and cancelled events are left out. Times and day names follow this Mac's time zone and language.

`join` is a video-call link found in the event's URL, then its location, then its notes: Zoom, Google Meet, Microsoft Teams, Webex, FaceTime, Whereby, Chime, GoTo, Slack huddles and Discord. A link counts only when its host is the service's own (so `evilzoom.us` doesn't) and its path is a meeting's, and only over https. Links wrapped by Outlook SafeLinks or Google are unwrapped first.

**Add Event.** A button with `"kind": "add-event"`, on a card whose source is a calendar source, opens a **New Event** form in the panel, starting now. On a [`month`](https://legatobar.com/docs/card-time.md#month) card with another day chosen, it starts on that day instead, at the same time.

The button can fill it in: a `title` of 1–80 characters (a template filled from the answer, or plain text; default blank, and the form won't add the event until it has one), a `duration` from `5m` to `12h` (default `1h`), and a `calendar` by name (default: the calendar Calendar adds new events to).

The form also takes a location, all-day, the start and end, repeat (every day, weekday, week, two weeks, month or year), the calendar, an alert, a URL (`https://` is added when it's typed without one) and notes; **Add** (or Return) saves it and the card shows it at once. Unlike other buttons, it stays on a card that has nothing to show, since a free day is when it's wanted.

Run from Shortcuts, the button adds the event as its settings say, with no form (titled "New Event" when it sets no title); chosen in Spotlight, it opens the form on its page.

**Calendar access.** The first time a calendar source runs, its first card says what it would show and offers **Allow Calendar Access**, which brings up macOS's prompt; Legato never asks at launch. If access was turned off, the card offers **Open Privacy Settings** instead. If Legato may only add events, the card offers **Allow Full Access**; if an organization manages access, the card says so. Other cards on the same source wait for the first.

## Reminders sources

A source with `"kind": "reminders"` reads this Mac's reminders, the ones Reminders shows, through macOS itself, and a checklist row can check one off. Nothing leaves the Mac. The smallest page is a count and a checklist:

```json
"sources": { "reminders": { "kind": "reminders", "show": "overdue+today" } },
"cards": [
  { "id": "due", "type": "stat", "label": "Due today", "value": 0,
    "source": { "ref": "reminders", "map": { "value": "today_count",
      "delta": { "if": { "path": "overdue_count", "gt": 0 }, "then": { "template": "{overdue_count} overdue" }, "else": { "template": "None overdue" } } } } },
  { "id": "todo", "type": "checklist", "label": "Today and overdue", "mark": "fill", "items": [],
    "source": { "ref": "reminders",
      "map": { "items": { "each": "items", "limit": 20, "fields": { "text": "title", "detail": "detail", "done": "done" } } },
      "empty": { "when": { "path": "count", "equals": 0 }, "text": "{empty}" } },
    "itemAction": { "kind": "complete-reminder", "label": "Complete", "icon": "checkmark" } }
]
```

| Field | Required? | Meaning |
| --- | --- | --- |
| `kind` | yes | `reminders`. |
| `show` | no | `overdue`, `today` or `overdue+today` (the default), in `items`. `dashboard` and `all` answer differently (below). A reminder due on a date is overdue from the next day; one due at a time, from that time, as in Reminders. |
| `lists` | no | Reminders list names to include, as Reminders shows them. Default: every list. |
| `list_ids` | no | Lists to include by id, a `lists` row's `id`, with `show` `dashboard` or `all`. A list's page takes it from its link: `"list_ids": ["{param.list}"]`. Not with `lists`. |
| `days` | no | With `dashboard`: how many days after today `upcoming` reaches, 1 to 31. Default 7. |
| `completed_days` | no | With `dashboard`: how many days `completed` and `by_day` cover, today included, 1 to 31. Default 7. |
| `every` | no | A safety refresh, default `5m`. The source also refreshes within seconds of a change in Reminders, when a timed reminder falls due, at midnight and when the time zone changes. |
| `derive` | no | As for any source. |

The answer has `items`, oldest first (on one day, reminders without a time before timed ones), and `count`, `overdue_count`, `today_count` and `empty` ("All caught up").

Each item has `id`, `title`, `line` (the title, with when it's due after it when that says something: "Call vet · 9:30 AM", "Pay rent · Yesterday", and just "Water plants" for one due today with no time), `due` (ISO 8601, or null for a reminder due on a date), `due_date`, `all_day`, `time` ("9:30 AM", or empty), `when` ("Today 9:30 AM", "Mon, Oct 26"), `due_text` (what `line` adds), `list`, `color` (the list's, `#RRGGBB`), `overdue`, `today`, `priority` (`high`, `medium`, `low` or `none`), `repeat` (how often it repeats: "Daily", "Weekly", "Monthly", "Yearly" or "Every 10 days", "Every 3 weeks"; a rule on set weekdays still reads "Weekly"; empty when it doesn't repeat), `detail` (the line Reminders shows under a title: `due_text`, `list` and `repeat`, those that say something, joined with " · ", such as "9:30 AM · Home · Weekly"; map it to a checklist item's `detail`), `notes`, `url` and `done` (always false, for a checklist's `done`).

With the first three shows, only incomplete reminders with a due date are read.

**A whole overview: `show: "dashboard"`.** One read of every open reminder and those completed lately, for the [Reminders](https://legatobar.com/services/reminders) pages:

- `due`: today's reminders (without a time first, then by time, including those whose time has passed), then earlier overdue days, newest first. Each reminder once. `due_count`, `today_count`, `overdue_count`.
- `upcoming`: due in the `days` after today, by day. `upcoming_count`.
- `undated`: no due date, the oldest made first. `undated_count`.
- `lists`: every list, the most open reminders first, each with `id`, `title`, `color`, `open`, `overdue` (those due before today, the ones under Overdue) and `detail` ("8 open · 2 overdue", "None open"). `list_count`.
- `completed`: completed in the last `completed_days`, newest first, each with `id`, `title`, `list`, `list_id`, `color` and `completed` (ISO 8601, for `|ago`). `done_count`, `done_today`, and `by_day`: one `{label, date, count}` per day, oldest first, for a `columns` card.

**One list: `show: "all"`.** Every open reminder in `items`, overdue (oldest first), today, later, then undated, with `count`, `list_title` (for the page's `title_from`) and `empty`, which says so when the list is gone.

Rows from these two shows add `list_id`, `group` (the heading they go under: Today, Overdue, Tomorrow, "Thu, Nov 19", Upcoming or No date; map it to a checklist's `section`), `day` ("Today", "Mon, Oct 26", empty with no date), `info` (day, time and list: "Today · 9:30 AM · Home"), `info_short` (without the list), `repeats` (true or false, for a repeat badge) and `priority_mark` (`!!!`, `!!`, `!` or empty, as Reminders puts before a title). An undated row has a null `due` and `due_date`.

Ticking a repeating reminder does what Reminders does: the occurrence is kept as completed and the reminder moves to its next date, with the same `id`. Ticking from one card reads every reminders source again, so another page showing the same reminder catches up at once.

Sections, tags, flags, subtasks and a list's own order aren't available to apps, so a page can't show or filter by them. A subtask is an ordinary reminder in its list.

A checklist on a reminders source can carry `"itemAction": { "kind": "complete-reminder", "label": "Complete" }`: ticking a row marks it done at once (with `"mark": "fill"`, its circle fills, as in Reminders), and after a moment marks that reminder done in Reminders and fades the row out. Ticking it again during that moment undoes it, and nothing changes in Reminders. (Every checklist row action waits the same way.) It finds the reminder by the row's `id`. `complete-reminder` works only as a checklist's `itemAction` on a reminders source, not as a button.

**Reminders access.** It's a separate permission from Calendar. The first read's card offers **Allow Reminders Access**, which brings up macOS's prompt; if access was turned off, **Open Privacy Settings**.

