I'm trying to create a system volume mute toggle button that operates like the stock one, meaning that one press mutes the system and changes the icon to a mute icon (volume w/ slash and no lit up "waves") and the next press returns system volume to wherever it was and changes the icon to the alt version of mute (volume w/ slash but lit up "waves").
I can't do this with a simple TouchBar button because those can't have two icons. So I'm using a widget with the 'Run AppleScript and Show Return Value' setting. I've set the predefined action to Mute, the stock icon to mute on, the alt icon to mute off, and the AppleScript to this:
return output muted of (get volume settings)
Then I set the 'activate alternate color and icon' regex to 'true'.
It almost works. Pressing the button does toggle system volume mute on/off. But the icon doesn't change, nor does the text of the button. --> Unless I reset the touchbar somehow (I currently have it set to show me different buttons when I press cmd/opt/etc). So when I reset the TouchBar then the button shows the proper state (e.g. the word "true" and the mute ON icon when system volume is muted, and the word "false" and mute OFF icon when system volume is note muted).
How can i get the button to update (and thus, the icon to update) without having to restart/reload the touchbar?