Changing the macro name (programmatically) to provide the user with more information in the system menu

I'm creating a macro which uses a new technique that modifies the macro name in order to place new information on the system menu. The technique is quite interesting so I've decided to post it here before I even upload my new macros which use it (to monitor the CPU load and free RAM.)

Each KM Group has a feature called "Display in Menu Bar" that includes an option called "With Title from Variable" that lets you place a text message in the Menu Bar. That's useful enough, but I've found another trick to enhance that. For example, I've developed a CPU load measuring that places an icon on the system menu with a number representing the load, like this:

Screenshot 2024-06-01 at 18.02.10

(Notice that the red/yellow/green icon colour changes dynamically based on whether the load is light or heavy.)

But I noticed that when you click on the icon, you get the name of the macros in that group below the icon.

Screenshot 2024-06-01 at 18.03.58

So I was thinking, is there any way to programmatically change the name of the macro so that useful information could be displayed there in place of the macro name?

Sure enough, it wasn't that hard to do. At the top of your macro, you have to include this action:

image

Then during your macro you have to place the text you want to display into this action: (in this example I'm just placing a random number as the new name)

image

Normally you wouldn't use a random number, you would use some interesting data. In my case I'm placing the last ten readings of a system setting as the new name.

Then you execute this macro:

image

When you do this, the name of the macro will change to become the name of whatever data you placed into the variable LocalNewName. And when that happens, it will also place that data into the system menu, so it will look something like this:

Screenshot 2024-06-01 at 18.10.07

Notice that the value I assigned to LocalNewName is now the new macro title, and therefore, is now visible under the Macro Group's icon. This is a new way (at least for me) to provide information to the user.

As a free bonus tip, which I plan to exploit, you aren't limited to ASCII characters in the name of the macro, or in the variable that you assign to the group! Emojis will also work, and I plan to use this to pass more information to the user.

If you add the Group Status Menu trigger, you can configure the display in the menu, which is a Token Text string, so you can do this:

Yes, I know. This post was about getting "more information" than just that string. My method involved changing the macro name so if you clicked on the menu icon, you would get additional information. In my case, the menu shows "current information", and if you click on the icon, you get more information, specifically a list of earlier readings.

For example, the menu icon for one of my macros shows the current CPU load, but if you click on the icon, the name of the macro that is displayed beneath it is a series of recent historical readings. I didn't want all that extra information to be displayed in the menu bar.

I'm confused.

With the Group Status Menu trigger configured to display a variable instead of the macro name, you can put whatever information you want in the global variable and that will be displayed as the menu title.

Similarly, the status menu title can be a variable.

image

Any time you update the Group Title variable, the menu title will change, and any time the menu item is shown, the Macro Title variable is displayed.

So you don't have to rename the macro, just change the variable.

Am I missing something?

1 Like

You are perfect, and you are never wrong.

I was conflating the "Macro Group" "Display Variable" feature with the "Group Status Menu trigger" "Display Variable" feature. I had never noticed the second one until just now.

2 Likes