System event
Runs the macro when the Mac's appearance, displays, power source, desktop space, mounted drives or audio output change.
The Mac changes: event
Keyboard Maestro: Appearance, Power, Display, Space, Volume, AudioOutputDevice
Details #
Fires when one of six things about the Mac changes. event says which, and value or name narrow it.
| event | Fires when | value | name |
|---|---|---|---|
appearance | The system switches between light and dark | light or dark (the new one) | not used |
power | The Mac switches between mains and battery | ac or battery (the new one) | not used |
display | The set of displays changes: one is plugged in, removed or rearranged | the number of displays now, as text | not used |
space | The active desktop (Space) changes | not used | not used |
volume | A drive or disk image is mounted or unmounted | mounted or unmounted | the volume's name |
audioOutput | The default sound output device changes | not used | the new device's name |
value has to equal the event's value (any case). name has to appear inside the event's name (any case), so name: "AirPods" matches "Kyle's AirPods Pro". Leave either empty to match all.
{{triggerValue}} holds the event's value: dark, battery, mounted and so on, or the display count. It is empty for space and audioOutput, which have no value.
Display changes are bundled: macOS reports several changes while the displays rearrange, and Switchboard fires once, shortly after the last. Power only fires when the source really changes, not on every battery reading.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
event | one of | Yes | appearance display power space audioOutput volume | Required. appearance, display, power, space, audioOutput or volume. |
name | text | Only fire when the name contains this text. For volume and audioOutput. | ||
value | text | Only fire for this value. See the table. |
Every trigger also takes Limits: a cooldown, the first time each day, every nth time, twice within seconds, a chance, only while you are at the Mac, on one Mac, or in a State. See Limits on any trigger.
Examples #
- The Mac switches to dark mode
- Show “Dark mode is on”
- A volume is mounted
- Show “Drive {{triggerValue}}”
Gotchas #
The
volumeevent is about drives and disk images, not sound volume.displayreports how many displays there are now, as text. It does not say which was added.powerfires only on a change after Switchboard started. It does not fire at launch for the state you are already in.The appearance event is sent a moment after the change, so the new value is already in place when the macro runs.
A trigger with an
eventthat is not in the list never fires.