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 [].
appis the name under the icon.bundleIDis the app's bundle id, when the icon points to an app.badgeis the badge text as a string, such as"3". UseNumber(badge)for a count.
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
- macotron.app for running apps.
- macotron.ax for other accessibility reads.