Can scripts not update "SFSymbolDefaultIcon"?

Not sure why my script isn't working any ideas?
Any help is appreciated.

tell application "System Events"
	tell process "Finder"
		set fileMenu to menu "File" of menu bar 1
		if (enabled of menu item "Move to Bin" of fileMenu) then
			set btnColor to "255, 79, 75, 255" as string
			set btnIcon to "trash.fill" as string
		else if (enabled of menu item "Eject" of fileMenu) then
			set btnColor to "255, 79, 75, 255" as string
			set btnIcon to "eject.fill" as string
		else
			set btnColor to "30, 30, 30, 25" as string
			set btnIcon to "trash.slash" as string
		end if
	end tell
end tell

set btnJson to "{\"BTTTriggerConfig\" : {\"BTTTouchBarItemIconType\" : 2, \"BTTTouchBarItemIconHeight\" : 22, \"BTTTouchBarItemSFSymbolAlternateIcon\" : \"" & btnIcon & "\", \"BTTTouchBarItemSFSymbolDefaultIcon\" : \"" & btnIcon & "\", \"BTTTouchBarButtonColor\" : \"" & btnColor & "\"}}"

tell application "BetterTouchTool"
	update_trigger "BC96F282-CAD1-4CFA-B750-C3CAB36CA1D2" json btnJson
	return btnJson
end tell

The button color is being correctly updated but the SF symbols icon is not being applied? I've tried specifying the icon type and icon size in the script but all to no avail?

To anybody in the future looking at this issue, I ended up resolving it by returning JSON data directly to BTT like so (AppleScript Widget):

tell application "System Events"
	tell process "Finder"
		set fileMenu to menu "File" of menu bar 1
		if (enabled of menu item "Move to Bin" of fileMenu) then
			set btnColor to "255, 79, 75, 255" as string
			set btnTextColor to "100, 1, 0 255" as string
			set btnIcon to "trash.fill" as string
		else if (enabled of menu item "Eject" of fileMenu) then
			set btnColor to "255, 79, 75, 255" as string
			set btnTextColor to "100, 1, 0 255" as string
			set btnIcon to "eject.fill" as string
		else
			set btnColor to "43, 44, 46, 255" as string
			set btnTextColor to "128, 128, 128, 255" as string
			set btnIcon to "trash.slash" as string
		end if
	end tell
end tell

return "{\"sf_symbol_name\":\"" & btnIcon & "\",\"background_color\":\"" & btnColor & "\",\"font_color\":\"" & btnTextColor & "\"}"

This was a bug and should be fixed in 3.560 alpha which will be online in about 10 minutes. (Get via check for alpha version updates)

1 Like

Ah, glad to see it's fixed! Will check out the alpha. Thanks again.