Here is an example. This would update the text, color and icon when clicking the item. It would toggle between the text "on" and "off" (Icon change requires the latest BTT alpha due to a bug I just discovered).
You need to replace the UUID with the UUID of your menubar item, you can get that by right-clicking your item in the BTT configuration.
(async ()=> {
let isOn = await callBTT('get_number_variable', {variable_name:'isButtonOn'})
var offJSON = {uuid: '2DE6D5F2-5FCF-495C-8E94-64E7DFB109AD',
"text" : "Off",
"sf_symbol_name": "bolt.slash.circle.fill",
"background_color": "200,50,100,255"
}
var onJSON = {uuid: '2DE6D5F2-5FCF-495C-8E94-64E7DFB109AD',
"text" : "ON",
"sf_symbol_name": "bolt.circle.fill",
"background_color": "50,200,100,255"
}
if(isOn === 1) {
await callBTT('update_menubar_item', offJSON);
await callBTT('set_number_variable', {variable_name:'isButtonOn', to: 0});
} else {
await callBTT('update_menubar_item', onJSON);
await callBTT('set_number_variable', {variable_name:'isButtonOn', to: 1});
}
returnToBTT('done');
})();