A condition becomes true
Runs the macro when any condition turns true, turns false, or either, instead of only checking it when something else fires.
A condition becomes true
Details #
Every condition Switchboard can check (the front app, a window title, the network, the battery, a file, an element on screen, a variable, a script, an extension) can also be a trigger. Switchboard keeps watching the condition and runs the macro when its answer changes: when it becomes true, when it stops being true, or either.
It only reacts to a change. If the condition is already true when Switchboard starts, or when you edit the library, nothing runs. Turn on fireIfAlreadyTrue to run once for that case.
A change has to last hold seconds (2 unless you say otherwise) before it counts, so a battery that wobbles around 20% does not run the macro five times. After it runs, the same edge is ignored for cooldown seconds (10).
Most conditions cost nothing while they wait: they are read again only when something that could change them happens (an app switch, a network change, a power event). Conditions that nothing announces are polled: script and extension conditions every 30 s (at least 5 s), modifierDown, fileExists and on-screen elements every few seconds. Set every on the condition to change that. AI conditions (model) cannot be watched, because every read costs money.
The macro gets these inputs, plus what the condition looked at (the window title, the network name, the battery level):
| Input | What it holds |
|---|---|
edge | true or false: what the condition became. |
since | When the condition last changed before this, if it had. |
{{triggerValue}} is the edge.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
condition | condition | Yes | Required. Any condition, written as in an Only if list. | |
cooldown | number | Seconds before the same edge may run the macro again. Default 10. | ||
edge | one of | true false both | true (default), false or both. | |
fireIfAlreadyTrue | yes / no | Also run once at start when the condition is already true. | ||
hold | number | Seconds the new answer must last. Default 2; 0 reacts at once. |
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 battery is below 20% becomes true
- Show a notification “Battery low”
Gotchas #
A condition that stays true never runs the macro again. To run on a schedule while it is true, use a Periodic trigger with an Only if.
Two macros that watch the same condition share one reading.
The macro's own Only if is still checked before it runs.
Problems with a watched condition (one that cannot be watched) show in Settings, Health.
See also #
A value changes, A State starts or ends, Wait until a condition holds, Triggers that watch: becomes true, States, waiting runs