update_touch_bar_widget crashing (?) widget when updating icon

I'm not entirely sure if this is a bug or just me not understanding scripting... But here goes:

Describe the bug

I'm trying to update a widget's icon via AppleScript. If I use...

tell application "BetterTouchTool"
    	update_touch_bar_widget "FC72A1C1-81BA-4028-8332-99F258F0C2F9" icon_path "~/Pictures/Touch Bar Icons/Battery/100.png"
end tell

... the widget completely disappears from the Touch Bar, making nearby icons kind of crash into one another. Disabling and re-enabling the widget then restores the proper configuration, with the icon properly updated (!!).

If I use...

tell application "BetterTouchTool"
    	update_touch_bar_widget "FC72A1C1-81BA-4028-8332-99F258F0C2F9" icon_path "~/Pictures/Touch Bar Icons/Battery/100.png"
    	refresh_widget "FC72A1C1-81BA-4028-8332-99F258F0C2F9"
end tell

... it works more or less as expected, but the icon flickers each time it is updated, as do the ones next to it. I presume refresh_widget just does quickly what a manual disable/re-enable does slowly.

Am I doing something wrong? I thought update_touch_bar_widget was supposed to suffice to update an icon.

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
Touch Bar

Device information:

  • Type of Mac: 2017 15" MBP
  • macOS version: 10.13.5
  • BetterTouchTool version: 2.530

shouldn't be path be absolute? Like /Users/yourname/ instead of ~ - though I might be wrong, you'd have to look it up from docs

Tried it, doesn't matter.

Also, the path is definitely recognized – as is the UUID – since the icon is updated to whatever path I specify. It's just that I don't see it at first because the icon disappears – I must bring it back by means of refresh_widget or a manual disable/enable to see it.

Also waiting for a reply here. Still same behavior with 2.645 and macOS 10.13.6. The widget/icon disappears from the Touch Bar if only update_touch_bar_widget is used, and it flickers if used conjunction with refresh_widget.

Having a problem here updating anything on a widget:

update_touch_bar_widget "5F36B040-BDDA-4585-A6DB-0F47C3592C8B" text "1234"

update_touch_bar_widget "5F36B040-BDDA-4585-A6DB-0F47C3592C8B" background_color "255,100,100,255"

neither of these are updating my widget. I've tried webserver and AppleScript

Has anyone had any success?

update_touch_bar_widget only works with the Apple Script or Shell Script widget. Are you using any of them? Otherwise you'd need to use the update_trigger function

Andreas, could you please also have a look at my original issue? Just see the first post in this thread. I can't for the love of it figure out what I'm doing wrong. My scripting target is definitely a widget, but the disappearing/flickering issue means I have to update the icon as little as possible, otherwise I get constant movement in my Touch Bar. That can't be how it's supposed to work!

Try to provide a title as well as the icon, but in the settings make it "icon only".

1 Like

Jolly, that worked! Thank you.

I already had the widget on "icon only", though. (And it already had a title/text.) So this still seems like a bug to me. But of course it's workable now.

Yep sounds like a bug :slight_smile: I'll fix that.

I'm using Execute Shell Script/Task

Then it should work fine. Is the UUID correct? Is external scripting allowed?

double triple checked the UUID, yes external scripting is allowed. I have a secret set, it prompts me for it when I run the script.

I've also tried a run AppleScript widget. The UUID is that of the AppleScript widget itself. Still no joy:

tell application "BetterTouchTool"
update_touch_bar_widget "5F36B040-BDDA-4585-A6DB-0F47C3592C8B" text "1234" shared_secret "abc"
end tell

if possible please go to the about tab in BetterTouchTool and click the "export debug information" button. This will create a folder called BetterTouchToolDebug on your desktop, if you send that to me I may be able to see what's wrong (andreas@folivora.ai)

I think there was some confusion as to what I refer to as Script Widget :slight_smile:
You just have normal buttons set up and assigned scripts that are triggered when they are pressed.

Widgets are added using the + Widget/Gesture button in BTT. The point of script widgets is that they run a script to determine what they display.

If you want to update a normal button/trigger (which usually just shows static text) you can use the update_trigger function like this:

tell application "BetterTouchTool"
	update_trigger "5F36B040-BDDA-4585-A6DB-0F47C3592C8B" json "{\"BTTTouchBarButtonName\" : \"The_New_Button_Title\"}"
end tell

That did it. Many thanks.