Changing touchbar icon to alternative if appleScript return value is greater value set


#1

Hi I have made a bar button that shows me the percentage output of my CPU. I'm looking to have the icon change from the standard (white) version to red when the appleScript return value is greater than or equal to 90.
I currently have the standard icon in icon slot 1 and the red icon in slot 2 however I just can't seem to figure out how to call the alternative icon when the value is greater than (I've tried >89) but doesn't seem to work. I have managed to get it to the alternative if I make the value static at 90 but anything above this and it returns to the icon 1, any thoughts?


#2

You can't check for higher or lower value there. However, in your script, you can check whether it is higher or not and return a value accordingly.
Ex:

if CPU > 89 then
    return "red"
else
    return "white"
end if

#3

Thanks cfstcyr for getting back to me.

Unfortunately I was hoping for the script to return an Int value since it's displaying the percentage value of the CPU used next the icon which would change depending on the value.

I see though why you suggest this, since technically it would work and answer my question if the icon was independent to the Int value return but I was hoping to do it in one script rather than two.

I'll pop the feature in the feature request section.

I appreciate you giving me an answer though.