A value changes
Runs the macro when an expression's value is different from the last time it looked: a variable, a sensor reading, the clipboard length, the front app.
expression changes
Details #
Watches an expression, written in the same language as {{ }} values, and runs the macro when its value is different from the last time Switchboard read it. The macro gets before and after.
The expression is read again on app switches, window title changes, clipboard changes, network and power changes, shared variable writes and State changes, and on a timer every every seconds (10 unless you say, at least 1). The first reading never runs the macro.
A new value has to last hold seconds (2 by default) before it counts, and the trigger rests for cooldown seconds (10) after it runs.
| Input | What it holds |
|---|---|
before | The previous value. |
after | The new value. |
{{triggerValue}} is the new value.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
expression | text | Yes | Required. For example shared.mode or frontAppName(). | |
cooldown | number | Seconds before the next run. Default 10. | ||
every | number | Seconds between reads when nothing announces a change. Default 10. | ||
hold | number | Seconds the new value must last. Default 2. |
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 value of “shared.mode” changes
- Show “Mode: {{ after }}”
Gotchas #
Only
shared.variables are visible: a run's own variables die with the run.An expression that fails to evaluate is skipped until it works again.
See also #
A condition becomes true, A State starts or ends, Triggers that watch: becomes true, States, waiting runs