Browse the docs

App notification

Runs the macro when any app posts a macOS notification, matched on the app, the title and the body, with the text handed to the macro.

app notifies, saying body

Details #

Most apps never tell anything else what they are doing, but nearly all of them post notifications, and a notification already carries the app, a title and a body. This trigger listens to all of them. So "when Slack notifies and the body contains mentioned you" or "when Xcode says Succeeded" works with no setup in either app.

app is the notifying app's bundle id (the editor lists the apps that have notified lately). Left out, or any, every app counts. title and body are compared with mode: contains (the default), equals, regex or glob (* and ?, matching the whole text). A field left empty matches anything. Both must match. caseSensitive turns capital letters on, and excludeApps lists bundle ids that never start the macro.

{{triggerValue}} is the body (the title when there is none). The run also gets these as values you can use in any step: {{app}} (the bundle id), {{appName}}, {{title}}, {{subtitle}}, {{body}}, {{silenced}}, and, when the app sends one, {{thread}} and {{link}}. With mode set to regex, the pattern's groups are {{match[1]}}, {{match[2]}} and so on, and {{match[0]}} is the whole match. They come from the body pattern, or from the title's when there is no body pattern.

silenced is true when a Focus, or the app's own setting, kept the banner off the screen. Those notifications still exist, so a macro with the Only if state Deep work can collect what you missed.

How it reads. macOS keeps every notification it delivers, shown or not, in a private database. Switchboard Engine reads it, read only, and only while a macro has this trigger on. That needs Full Disk Access for Switchboard Engine, and Settings › Permissions shows a row for it once a notification trigger exists. Without it, Switchboard reads the banners on screen instead through Accessibility. That works, but it misses notifications a Focus silenced and ones that vanish at once.

Each notification starts a macro once, even if the app edits it afterwards, and Switchboard never reacts to its own notifications, so a macro that shows a notification cannot start itself. On start nothing is replayed; use Read recent notifications to read what arrived before.

Parameters #

ParameterTypeRequiredValuesWhat it does
apptextBundle id of the notifying app. Any app when left out.
bodytext
caseSensitiveyes / noCompare capital letters exactly. Default off.
excludeAppslist of textBundle ids that never start the macro.
modeone ofcontains equals regex globcontains, equals, regex or glob. Default contains.
titletext, body: What the notification's title and body must say. Empty matches anything.

Examples #

Bring Terminal forward when Xcode says it built
When
  1. Xcode notifies with “Succeeded” in the body
Do
  1. Activate Terminal
Open in Switchboard to try it
Say who mentioned you in Slack
When
  1. Slack notifies with a body matching “(.+) mentioned you”
Do
  1. Show “{{match[1]}} needs you”
Open in Switchboard to try it

Gotchas #

  • The database is private to macOS. Its layout has held from macOS 12 on, but nothing promises it. If a macOS update changes it, Switchboard falls back to banners and says so in Permissions.

  • The body and title go into the run's trace like any other value. Turn the macro off, or turn off the last notification trigger, and Switchboard stops reading the database.

  • A notification from an app that has not notified yet is not in the editor's App list; type its bundle id instead.

  • The macro only reads and reacts. It cannot dismiss, click or answer a notification.

  • Not fired reasons: disabled, groupOff, scope, paused, conditionFalse.

See also #

Read recent notifications, Show notification, Window title change, Triggers