Enable/disable Touchbar widgets via AppleScript

Hi there,

would it be possible to add something like "toggle_touch_bar_widget" to the AppleScript commands that takes a UUID and a boolean, so one could either enable or disable a specific widget via AppleScript?

As far as I've been able to find out, currently I can only use "update_touch_bar_widget" and "refresh_widget" to interact with Touchbar widgets. Neither can be used to enable/disable widgets to my knowledge.

Using "update_touch_bar_widget" to set the text to an empty string will result in the widget not being shown, but only for widgets that don't have the "Show only icon, no text" option set. I'm using a lot of fancy little widgets that only make use of icons and alternate colors/icons to inform me about certain things, and many of them need only to be shown at certain times. I was not able to figure out any way to hide them via AppleScript (or even via BTT actions, for that matter, because in that case I could just create a named trigger and call that from my AppleScript).

Did I miss something or is what I'm trying to achieve really not possible at the moment?

Thanks, Manu

You can use the update_trigger function

tell application "BetterTouchTool"
    update_trigger "2F34005D-4537-464D-94E9-A7F42DA39DF1" json "{\"BTTEnabled2\" : 0}"
end tell

For Touch Bar items the property is called BTTEnabled2, for most other trigger types it's BTTEnabled (legacy reasons)

3 Likes

Works like a charm, thanks for the super quick reply! :slight_smile: