Put an Icon & Menu on your Mac OS/X Menu Bar

This is a tutorial for how to use KM and BitBar ( https://github.com/matryer/bitbar ) to add an icon to your OS/X Menu Bar - a dynamically-generated icon and drop-down menu.

  1. Install BitBar. Remember that when you install it, it opens a dialog asking for the folder to put Plugins in. Create a folder and select it.

  2. Import my macros. There’s 3.

Set BitBarMenuExample.kmmacros (11.5 KB)

  1. Edit the macro named “_Setup Example !!!DO FIRST!!!”, and change the path to the plugin - the plugin will be created for you, but change the path first.

  1. Run “_Setup Example !!!DO FIRST!!!”. You can select all the actions and click the “try” button, or if there’s a better way, go for it. This will create the plugin script file.

  2. You should now have a “bell” icon in your Menu Bar. Click it and a menu will drop down. If you click “Example Menu Item”, it will call my example macro.

  3. Change the Icon and/or menu text in the macro "Set BitBarMenuExample__Script", then re-run it (it's is in the KM status menu). Check out the results.

Here’s the details of how this works:

Plugin File

You can read up on the details of the BitBar plugin format, but this is our plugin file, called “DanTimer.30s.applescript” unless you changed it. The “.30s.” portion means BitBar should refresh it every 30 seconds.

set AppleScript's text item delimiters to {" "}
tell application "Keyboard Maestro Engine" to getvariable "BitBarMenuExample__Script"

It’s an AppleScript script that gets the contents of the Plugin (i.e. the Icon and Menu Bar) from the KM variable “BitBarMenuExample__Script”.

So every 30 seconds, it asks KM for that variable, and it becomes the icon and menu.

Our Dynamic Menu Script

Here’s what we’re generating in KM for the Plugin script:

  • The first line is the icon - it’s actually text, but we’re using an Emoji for the icon.
  • The three dashes say “the next is a menu”.
  • The menu line has the menu text before the |, and after it is an href that tells KM to execute the macro.

We can change this variable at any time, and when BitBar refreshes, the icon and menu will change.


Hopefully this all makes sense. If not, let me know. Have fun!

PS: This took me a while to set up, so if there's issues, please let me know - I want to get it right.


Some changes could be to make the user folder path with the tilde (~/Documents/BitBar…) so the username is not hardcoded in the macro.

Otherwise I would say thanks. Since the time you have joined the forum I have enjoyed you post and enthusiasm about KM.
And some of your questions expose new functionality of for me as a long time user.

Just wish I had more time to tinker. :slight_smile:

Good catch - I’ll change that in the next version. I also realized, as I was posting it, that I left the name of the script with “Dan” in it, but I figured there’d be other things to change also, so I let it go.

Thanks for the other comments. My enthusiasm comes from the fact that I’m a recently retired developer, still needing to tinker. Unfortunately I’m a Windows developer, and it doesn’t translate well to the Mac, and starting from scratch has never appealed to me.

But now with KM… Woo hoo! Having fun!


Very nice, I want to try this, but when I execute the .kmlibrary-file I get a Macro called Set BitBarMenuExample__Script and I can’t find the three scripts/macros, like _Setup Example !!!DO FIRST!!!.

Any idea what I should do? :slight_smile:

Hey @DanThomas

Any chance this could function like a KM palette item? For example I have a global palette that always up and several of the items are for window sizing and placing:

It'd be sweet to put my custom icons in the menubar and launch them by clicking on the icon in the menubar claiming the menubar space as a KM palette, or am I just dreaming?

I know I can put these items in the KM status menu but then lose the one click simplicity and immediacy the KM palettes provide.

Hey Bern,

Pretty far in la-la-land I'm afraid.  :sunglasses:


Child-reaching-out-dreams-moon-logo-design-symbol-icon-by-Alex-Tass sigh...

Sorry, but I just get one Macro in the link
Where is the macro “_Setup Example !!!DO FIRST!!!”?

Somehow the original file I uploaded got messed up. I've updated the first post with what I hope are the right macros. Please try it out and let me know. Thanks!