Header Buttons via script

Header Buttons via script

@Matheus Alves

Hello everyone, good morning.
I’m creating a custom widget that receives alarm notification, I took advantage of this header button functionality which is great and I’m using it, but I need to hide and show the icon via script

image

I saw it in a post that has how to modify the header, but have any parameters to manage header buttons? or is there any other way?
image