Browse the docs

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.

InputWhat it holds
beforeThe previous value.
afterThe new value.

{{triggerValue}} is the new value.

Parameters #

ParameterTypeRequiredValuesWhat it does
expressiontextYesRequired. For example shared.mode or frontAppName().
cooldownnumberSeconds before the next run. Default 10.
everynumberSeconds between reads when nothing announces a change. Default 10.
holdnumberSeconds 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 #

Say the shared mode when it changes
When
  1. The value of “shared.mode” changes
Do
  1. Show “Mode: {{ after }}”
Open in Switchboard to try it

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