How to fine-tune your text output on the macOS Menu Bar

I have two tips here for people who want to put text in their macOS menu bar at the top of the screen. I don't see a lot of people doing that, but it's a very handy feature in Keyboard Maestro.

The problem that I observed is that it can be visually distracting if either:
(a) the text you display is not in a fixed-width font, or
(b) your text is not always the same number of characters,
because then it makes everything to the left of the text bounce left and right, once per second.

There are two techniques that I needed to use to address this problem.

First, I padded my numeric values on the left with leading zeros, so that the number of digits displayed is always the same. Here's the code I used to solve that:


Second, I needed to change the font that is used, because the default font is not fixed-width (sometimes called "monospaced.") You need a fixed-width font or else everything to the left will bounce left and right. Here's how I solved that problem:


Please notice the difference in the size of the two sets of digits, above. The first set of digits in the "tr" command are just characters created with the keyboard, while the second set of digits were created by locating (and double clicking on) a different font in the macOS Character Viewer, in this location:

One last tip: you might want to move your KM-generated menu bar items to the left of the menu bar, which can be done by pressing COMMAND-Left-Mouse-Button and dragging it to the left. It's interesting to note that as you drag the items around the screen, they are still getting updated. I wasn't expecting that!

My latest macros are finished, but I'll test them for a few days before publishing them here.