Browse the docs

switchboard var

Reads and writes the shared variables macros keep between runs.

Details #

A variable named shared.x in a step is kept between runs and across macros. switchboard var reads and writes the same variables from a script, a shell or another app. A name without shared. gets the prefix.

switchboard var set mode "deep work"
switchboard var get mode
switchboard var unset mode
switchboard var list --json

get prints the value and a newline. A variable nothing has set prints nothing on standard output, says so on standard error and exits 1, so a script can tell it from a variable set to an empty value (an empty line, exit 0); $(switchboard var get x) is still empty either way. set stores a number as a number and anything else as text, and refuses a name with spaces or other characters a {{shared.x}} reference can't use. The engine has to be running.

Imported BetterTouchTool scripts that call get_string_variable and set_string_variable are rewritten to these commands.

Parameters #

switchboard var get|set|unset|list [name] [value] read or change a shared variable (the ones named shared.x in steps)

Gotchas #

  • Exit code 69 means the engine is not running; 64 a name that can't be a variable name.

  • Only shared. variables are reachable: the others exist only while a run does.

See also #

Set variable, GET /vars, Variables and expressions