Six Colors
Six Colors

by Jason Snell & Dan Moren

Childhood Cancer Awareness Month

This month, join us and Relay FM in supporting St. Jude.

By Jason Snell

Put anything in your Mac’s menu bar with BitBar

BitBar in action
Three BitBar plugins in action.

I really can’t recommend Mat Ryer’s BitBar enough. It’s a free Mac utility that lets you put more or less anything you want in your menu bar. I keep finding more uses for it—at this point I’ve got four separate BitBar items in my menu bar.

At its simplest, BitBar is an app that runs plug-ins that display information in your menu bar. (It’s named because it was initially built to display Bitcoin prices.) There’s a whole collection of plug-ins at getbitbar.com, so if you’re not comfortable writing your own, you might find exactly what you want. It’s also easy to modify existing plugins to do what you want—all a BitBar plugin is, is a script that runs, gets data, and then returns a value that is displayed in the menu bar.

Last week a friend of mine upgraded to Catalina and, in the process, lost an old Mac utility he used to display the currently playing track in iTunes/Apple Music. I suggested he look at BitBar, which has a plugin that does just that.

It turns out that while it worked, BitBar’s plugin didn’t do exactly what he wanted. Most notably, he wanted the current track to be displayed in the format Song Title - Album (Year) - Artist. Since this particular plugin was a shell script, I was able to open it in BBEdit and quickly customize it to meet his needs.

For example, the existing music plug-in didn’t display the year, but I was able to include a little bit of inline AppleScript within the shell script that did the trick:

year=$(osascript -e'
set theYear to "0"
tell application "Music"
    try
        set theYear to (year of current track as string)
    on error errText
        ""
    end try
end tell
if theYear = "0" then
    return ""
else
    return ("(" & theYear & ")")
end if
');

I also ripped out a bunch of features that my friend didn’t really want, like play/pause/next/previous controls and a bunch of metadata in the dropdown menu. (Yes, BitBar will let you not just create custom text in the menu bar, but in the items that display when you click on the menu bar item.)

Last week Dan Moren updated a plug-in that I wrote a while back that looks at the live-stream servers of our various podcast networks and displays the current number of listeners in the menu bar. (He re-wrote the thing in PHP, since that’s a language he’s comfortable with.)

I’ve also got the current temperature from my weather station in my menu bar thanks to BitBar. Since I was more comfortable writing in AppleScript than in a shell script, my weather “plugin” is a single line – osascript ~/weatherscript.scpt – that runs a small AppleScript script that queries my weather station and returns the current temperature data, which BitBar displays.

Finally, I use a tiny plugin that pings my Linode server and reports back the total ping time, which is useful in determining at a glance if I’m really having network issues or if it’s just my imagination.

If you’re comfortable in literally any scripting language that can execute on your Mac, you can build BitBar plugins to display anything you can think of in your menu bar.

If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.


Search Six Colors