That’s looking a bit more efficient, but I think you should increase the delay in the repeat loop to say 5.0 or 10.0, because you don’t really need to check the CPU temperature every second, and your app is still a bit greedy with the CPU usage, but that’s your choice.
Your .icns file is no good for the status item’s image, but you could use it for your saved AppleScript application’s icon.
Find your saved application file in a Finder window, then right click or cmd click the application file.
Select “Show Package Contents” from the pull down menu, then double click the “Contents” folder.
Then double click the “Resources” folder, then inside the that folder you should see the “applet.icns” file, so you can simply rename your custom .icns file with that same name, and drag it in the the folder to replace the original icon file.
As for displaying an image next to the status item’s title, you have three options, from easy to more difficult, and the more difficult options may require help from someone with “Monetary” OS, because the code I could post for the more difficult options, will work fine on my “Mojave”, but will probably not work on “Monterey”.
The first and easiest option is to use an emoji or symbol.
Go to the “Edit” menu in the Script Editor app, down at the bottom you will see the emoji menu item.
have a browse through the installed emoji’s and pictographs, and see if there is a picture you like.
Then you simply do this in your “changeStatusItemTitle:” function, like this.
statusItem's button's setTitle:("⚙️" & title)
The second option is to use one of the installed system images, which may be different on your OS, to the ones on my system, but you can find them here.
you would change the top of your script to something like this.
use framework "Foundation"
use framework "AppKit"
use scripting additions
property myApp : a reference to current application
property statusBar : missing value
property statusItem : missing value
property statusItemImage : missing value
set statusItemTitle to "Status Bar Title"
set my statusBar to myApp's NSStatusBar's systemStatusBar()
set my statusItemImage to myApp's NSImage's imageNamed:(myApp's NSImageNameAdvanced)
set statusImageSize to (statusBar's thickness()) - 4
statusItemImage's setSize:(myApp's NSMakeSize(statusImageSize, statusImageSize))
And you would change the top of the “displayStatusItem:” function to something like this.
set my statusItem to statusBar's statusItemWithLength:(myApp's NSVariableStatusItemLength)
statusItem's button's setTitle:title
statusItem's button's setImage:statusItemImage
statusItem's button's setImagePosition:(myApp's NSImageLeft)
So have a testing session with these first two options, and see if any of the ready made system pictures are what your looking for.
Otherwise create a png image file that you want to use, and I will show you how to load it into your application, although that might be the point where the OS differences might cause problems.
also it will be difficult to test in the Script Editor app.
if you do create your own image file, make it very small, as the height of the Status bar on my system is only 22 pixels in height, and yours may be different, but it will still be small in height.
You can get the height of your status bar with this code.
log (statusBar's thickness())
So your created image file should be 2 to 4 pixels less than you status bar height.
Or if you intend giving your app to others, who may have different screen sizes and resolutions.
Then make your image about 24 pixels in height, and it will be resized with the code I posted above.