macotron.notes
List the titles and folders of your Apple Notes, and open a note in the Notes app.
const notes = await macotron.notes.list();
macotron.launcher.set("notes", notes.map((n) => ({
id: n.id,
title: n.title || "Untitled",
subtitle: n.folder,
app: "com.apple.Notes",
onClick: () => macotron.notes.open(n.id),
})));
Notes
Both calls talk to the Notes app with AppleScript, run in a separate osascript process off the main thread. Notes opens if it is not running.
list(): Promise<Array<{ id: string; title: string; folder: string }>>
Every note in every account. folder is the name of the folder the note is directly in. Notes in Recently Deleted, and in folders inside it, are left out. Resolves with [] when the script fails, for example when access is denied.
A large library takes a few seconds, so do not call this on every keystroke. The notes.js plugin refreshes every five minutes.
open(id: string): Promise<void>
Shows the note with that id and brings Notes to the front. An unknown id does nothing.
macOS asks once whether Macotron may control Notes. If the user says no, turn it back on in System Settings → Privacy & Security → Automation.
See also
- macotron.launcher for the launcher items in the example.
- macotron.contacts, built the same way for people.
- The
notes.jsplugin.