Shell Script Widget disappears until BTT restarted

I have a Touch Bar shell script widget that I am not actually using to run a shell script. Instead, I use it:
• To display text received by BTT's web server (sent by a local app).
• As a button to trigger a Post Distributed Notification action.

BUG: After several minutes, the widget stops working until I choose "restart BTT" in the BTT menulet. When it stops working, its space on the touch bar becomes blank and the button trigger stops working.

my shell script seem to work fine here, could you post the full setup of yours? Which version of BTT are you running?

Thanks, Andreas.

Version 3.346

I hope the following tells you enough about the configuration of the widget:

"BTTWidgetName" : "No Name",
"BTTTriggerType" : 642,
"BTTTriggerTypeDescription" : "Shell Script / Task Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 136,
"BTTPredefinedActionName" : "Post Distributed Notification with Name",
"BTTPostDistributedNotificationName" : "bob.bttWidget.Pause",
"BTTShellScriptWidgetGestureConfig" : "/bin/bash:::-c:::-:::",
"BTTEnabled2" : 1,
"BTTAlternateModifierKeys" : -1,
"BTTRepeatDelay" : 0,
"BTTUUID" : "omitted for security",
"BTTNotesInsteadOfDescription" : 0,
"BTTEnabled" : 1,
"BTTModifierMode" : 3,
"BTTOrder" : 0,
"BTTDisplayOrder" : 0,
"BTTMergeIntoTouchBarGroups" : 0,
"BTTTriggerConfig" : {
"BTTTouchBarButtonCornerRadius" : 0,
"BTTTouchBarItemPadding" : 0,
"BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
"BTTTouchBarItemPlacement" : 2,
"BTTTouchBarAppleScriptStringRunOnInit" : true,
"BTTTouchBarAlwaysShowButton" : false,
"BTTScriptType" : 0,
"BTTTouchBarScriptUpdateInterval" : 0,
"BTTTouchBarButtonWidth" : 295,
"BTTTouchBarItemIconHeight" : 22,
"BTTTouchBarButtonTextAlignment" : 2,
"BTTTouchBarButtonUseFixedWidth" : 1,
"BTTTouchBarAlternateBackgroundColor" : "75.323769, 75.323769, 75.323769, 255.000000",
"BTTTouchBarAppleScriptUsePath" : 0,
"BTTTBWidgetWidth" : 400,
"BTTTouchBarItemIconWidth" : 22,
"BTTTouchBarShellScriptString" : "",
"BTTTouchBarButtonFontSize" : 19,
"BTTTouchBarIconTextOffset" : 5,
"BTTTouchBarButtonName" : "No Name",
"BTTTouchBarOnlyShowIcon" : false,
"BTTTouchBarFreeSpaceAfterButton" : 2,
"BTTTouchBarAppleScriptString" : "",
"BTTHUDText" : "Pause",
"BTTShowHUD" : 1

Wait, how is this displaying text received by the webserver?

I think the problem is that the script is empty, therefore implicitly returns an empty string, which tells BTT to hide the script. The "Always run when becoming visible" can cause the empty script to run, therefore hide the widget.

Curiously, it does work for a while!

I'm attempting to implement the update_touch_bar_widget command you describe on these 2 pages:

Instead of the shell script widget, is there a different touch bar widget that has no associated script but which can display the text received in a update_touch_bar_widget command?

Although I suspect it is irrelevant, the Swift code I use to send the update_touch_bar_widget http command is:

let bttURL = URL(string: "\(someText)")

let request = URLRequest(url: bttURL)
NSURLConnection.sendAsynchronousRequest(request, queue: bttOperationQueue, completionHandler: {,,_ in })

You can use a normal Touch Bar button and update it using the "update_trigger" function. E.g. to change the text it would look like this:

tell application "BetterTouchTool"

update_trigger "2F34005D-4537-464D-94E9-A7F42DA39DF1" json "{\"BTTTouchBarButtonName\" : \"New Name\"}"

end tell

or via the webserver:

"{\"BTTTouchBarButtonName\" : \"New Name2\"}"

If you are using swift anyways you could also write a custom BTT Touch Bar plugin (but depends on your use case)

Updating a normal touch bar button using the webserver method worked perfectly.

Thanks, Andreas. Your customer support is exceptional!