update_trigger replaces UUID

Describe the bug
When using update_trigger via the webserver to change a touch bar button the UUID of that trigger changes.

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
Touch Bar (possibly other triggers as well)

Device information:

  • Type of Mac: MacBook Pro (15-inch, 2016)
  • macOS version: 10.15.7
  • BetterTouchTool version: 3.560

Additional information (e.g. StackTraces, related issues, screenshots, workarounds, etc.):
Context: I'm working on Go bindings for BTT via the webserver. Most actions are keyed against a UUID. If that UUID changes it is difficult to have a long running application that updates a trigger via update_trigger.

It should not change the UUID unless you provide one in the json.

Doing something like calling

http://127.0.0.1:12345/update_trigger/?uuid=EFA654BA-D8A4-44F0-8239-54782D942240&json={\"BTTTouchBarButtonName\" : \"New Name2\",  \"BTTTriggerConfig\" : {\"BTTTouchBarItemIconHeight\" : 30}}

should keep the UUID intact. I just tried and it seemed to work fine here. With what kind of trigger did you try it?

Ah. I didn't realize providing a UUID, even if it hadn't changed, would reset it to a new UUID.

I have a couple commands in this utility I'm working on. What I did to test it was to pipe the output to jq changing a JSON property and then pipe that to the trigger update. Basically this:

go-btt trigger get 96BA0556-1B4E-483B-9510-3D1380C3D6F2 | jq -c '.BTTTriggerConfig.BTTTouchBarButtonColor = "255,255,255,255"' | go-btt trigger update 96BA0556-1B4E-483B-9510-3D1380C3D6F2

The background color changes as expected but the widget has a new UUID.

Now that I know if BTTUUID is not specified doing this works as expected:

go-btt trigger get 96BA0556-1B4E-483B-9510-3D1380C3D6F2 | jq -c 'del(.BTTUUID) | .BTTTriggerConfig.BTTTouchBarButtonColor = "255,255,255,255"' | go-btt trigger update 96BA0556-1B4E-483B-9510-3D1380C3D6F2

I'll make a note of this in the documentation for the library code.

Thanks for the explanation. :slight_smile: