Variables
Included with Macro DeckChange your variables from buttons and automations, and write any variable to a file.
The Variables page, with the variables of every integration
- Set, add to, toggle or append to a variable
- Counters and on/off switches without a plugin
- Write any variable to a file, for example for OBS
- Built in and always on, nothing to set up
Variables is built into Macro Deck and always on. It adds two actions: Set Variable changes the value of one of your variables, and Write Variable to File saves the current value of any variable in a file.
You create your own variables on the Variables page with New variable. A variable is Text, Numeric, Boolean or Color, and you can show it anywhere, for example in a button label with {{ vars.deaths }}.
Set Variable
Choose the Variable and an Operation:
- Set to replaces the value with the Value you enter.
- Add adds the Value to a number. A negative value subtracts.
- Toggle switches a true/false variable between
trueandfalse. - Append adds the Value to the end of a text.
Which operations you can pick depends on the variable's type. A number is rounded to the variable's decimal places on every write.
Some integration variables can be written too, for example the volume and mute variables of your speakers and microphones, or a variable another Macro Deck shares with this one. Such a variable only takes Set to: Add, Toggle and Append work only for your own variables. To switch a microphone between muted and unmuted with one button, use the Mute / Unmute action instead.
Write Variable to File
Write Variable to File replaces the content of a File with the current value of a Variable. Any variable works, also those of integrations and plugins. The file is created if it does not exist, but its folder must already exist, and you enter its full path.
Example setups
- A death counter: a button with Set Variable, Add and Value
1on the variabledeaths, and its label showsDeaths: {{ vars.deaths }}. A second button with Set to0resets it. - A mode switch: a Boolean variable
stream_modetoggled by one button, and other buttons check it with If / Else. - A text source in OBS: an automation on Variable Changed for the current song runs Write Variable to File, and OBS shows the file's text on stream.
Variables does not appear on the Integrations page and has no setup dialog. Its Variables category is always in the Add action dialog.
What you need
- Macro Deck 3
- For Set Variable: a variable of your own on the Variables page, or an integration variable that can be written
Set it up
Step 1: Create a variable
In the sidebar, click Variables and then New variable. Give it a Name, for example
deaths, and choose its Type, for example Numeric.Step 2: Add Set Variable to a button
On the Deck page, make sure the deck is unlocked (the button at the top right reads Lock) and click a button. The editor opens with Short Press selected. Click + Add action, choose Variables on the left of the Add action dialog and pick Set Variable.
Step 3: Choose the variable and the operation
Pick the Variable, choose the Operation (Set to, Add, Toggle or Append) and enter the Value, for example
1for Add. Toggle needs no value.Step 4: Show the value on the button
Put the variable into the button's label, for example
Deaths: {{ vars.deaths }}.Step 5: Press the button
Click Save and press the button. The variable changes, and every label, condition and automation that uses it follows.
Actions2
Put these on a button or run them from a flow.
- Set Variable
- Changes the value of one of your variables: set it, add to it, toggle it or append to it.
- Write Variable to File
- Writes the current value of any variable to a file and replaces what the file contained.
Frequently asked questions
Do I have to turn on the Variables integration?
No. It is built into Macro Deck and always on. It does not appear on the Integrations page, and its actions are always in the Add action dialog.
Why does Set Variable say the variable is read-only?
Most integration variables, such as the CPU load or the current OBS scene, only show a value and cannot be changed. Variables of your own that come from a template, or from a file without Allow write-back, are read-only too. Set Variable can change your other variables and, with Set to, the integration variables that can be written, such as volumes.
Why does Set Variable say the value does not fit?
The value does not match the variable's type, for example a word for a Numeric variable. Check the Operation and the Value in the action.
Why does Write Variable to File fail?
The File must be a full path, such as C:\Stream\song.txt or /Users/you/stream/song.txt, and its folder must exist. The action also fails while the variable has no value, for example when its integration is not connected.
How do I keep a file up to date all the time?
Create an automation with the event Variable Changed that watches the variable and runs Write Variable to File for the same variable. Your own variables can also read from a file directly: choose Read from file as the source when you create them.
More in Macro Deck
Macro Deck Companion
Included with Macro DeckControl the phones and tablets that run the Companion app: brightness, rotation, screen and screenshots.
Macro Deck Delegate
Included with Macro DeckRun scripts on another PC running Macro Deck and use the variables it shares.
Scripts
Included with Macro DeckBuild a set of actions once as a script and run it from any button, automation or other script.