macotron.notify
Post a system notification banner, or flash a short toast on the screen under the pointer.
macotron.keyboard.on("Copy date", "cmd+shift+d", () => {
const today = new Date().toLocaleDateString();
macotron.clipboard.set(today);
macotron.notify.toast("Copied", today, { color: "success" });
});
Toasts
toast(title: string, body?: string, opts?: ToastOptions): void
Shows a small HUD centered near the bottom of the screen under the pointer, 48 points from the edge, then fades it out. The title and body show as one line, "Title: body", and long text wraps. Only one toast shows at a time; a new toast replaces the current one. You can also call toast(title, opts) with no body.
| Option | Type | What it does |
|---|---|---|
position | "top" | "bottom" | Which edge of the screen. Default "bottom". |
duration | number | How long it stays, in milliseconds. Default 3000. |
color | string | "info" (the default: plain text, no icon), "success" or "green" (green check), "error", "failure" or "red" (red cross), "warning" or "orange" (orange triangle). "blue", "yellow" and #RRGGBB tint only the sfSymbol icon and leave the text in the normal color. |
sfSymbol | string | An SF Symbol to show before the text, in place of the color's default icon. |
Write the title as the feature name and the body as the message: toast("Layouts", "Saved 3 windows"). For a bare state, continue the title in lowercase: toast("Night vision", "off").
Notifications
show(title: string, body: string, opts?: { sound?, subtitle?, id?, url? }): void
Posts a banner through Notification Center. Banners show even while Macotron is the active app. Throws a TypeError when title or body is missing, or when url does not parse.
| Option | Type | What it does |
|---|---|---|
sound | boolean | Play the default notification sound. Default true. |
subtitle | string | A line between the title and the body. |
id | string | Posting again with the same id replaces the earlier notification instead of adding another. |
url | string | Opens when the user clicks the banner. The URL is stored in the notification, so the click works even after Macotron restarts. |
The first banner asks for notification permission. If the user denies it, banners are dropped without an error. The user can turn them back on in System Settings > Notifications > Macotron. Toasts need no permission.
macotron.notify.show("Pomodoro", "Break — 5 minutes", { id: "pomodoro" });
See also
- macotron.menubar for status that stays on screen.
- macotron.panel for anything the user needs to answer.