Toggling Buttons (Low Overhead / Low Lag Method)

Here are some changes I made to my own and some Golden Chaos toggling buttons such as "Enable Dark Mode" and "Do Not Disturb"

Note:

  • This setup makes the buttons update straight away rather than with any lag

  • This setup does not have any repeating scripts running in the background

  • However! If the setting is changed outside of the touch bar and the icon is on your primary bar, the icon will not update to match

As such this setup is best for items which are hidden behind a modifier key OR settings which always get changed from the touch bar... or if you just don't mind if their state might be incorrectly displayed occasionally.

Here I will use the Golden Chaos - True Tone Toggle as an example:

In this widget we are checking for the system variable is_true_tone_enabled every 2 seconds and IF it is on, using the alt colour for the icon otherwise using the default colour. This makes for a toggling button.

When the widget it pressed, it toggles True Tone and then the icon updates sometime in the next 2 seconds when the script runs again.

The advantage of this approach is that it will have the correct button state if you toggle True Tone from else where (like the system setting).

However the < 2 second delay can make the button feel laggy and runs a repeating script every 2 seconds for a setting you probably do not change very often.

So a different method:

Here we set the execute script to 0 (Will not repeat at all) and check "Always run when widget becomes visible"

Now the button will only update whenever it comes into view (This button is in the CRTL hotkey menu)

Next:

We add a second action to the button "Run Apple Script" and use the exact same script as the main widget.

This script does not have the alt regex setting but will use the one on the main widget.

Now, when we press the button, this new script action will run and set the button to the correct colour state without any lag.

NOTE: This script must be at the TOP of the list (BEFORE the toggle action) to work correctly. I initially presumed this would not work because the script runs BEFORE the toggle action but being async seems to mean the script returns after BTT has done the toggle action.

You can of course use this method for something like this volume mute script which I keep in the right corner of my main bar:

But bear in mind that if you use the system volume slider or a microphone remote etc and set it to 0, the mute button will not reflect this change.

Imprint | Privacy Policy