Macotron

macotron.dock

Read the badges that apps show on their Dock icons, such as the unread count on Mail or Messages.

const mail = macotron.dock.badges().find((b) => b.bundleID === "com.apple.mail");
console.log("unread mail:", mail ? mail.badge : "none");

Badges

badges(): Array<{ app: string, bundleID?: string, badge: string }>

One entry for each Dock icon that shows a badge. Icons without a badge are left out, and an empty Dock gives [].

Only apps in the Dock can be read. An app that is not running and not kept in the Dock has no icon, so it has no badge.

Badges are read through the accessibility API. Declare permissions: ["accessibility"] in macotron.plugin(). Without it, badges() returns [].

See also