Put anything in macOS menubar
Tags: engineeringmonday, macos, productivity, tools
Published: 2020-06-08 13:10:07

---
title: Put anything in macOS menubar
published: true
description: Run scripts in your favourite scripting language (PHP, Python, JS, Ruby, shell, ...) and display results in macOS menubar.
tags: engineeringmonday, macOS, productivity, tools
---

Run scripts in your favourite scripting language (PHP, Python, JS, Ruby, shell, Swift, Go, Perl, Lisp ...) and display output in macOS menubar. In no time.

BitBar is a macOS app that supports custom menubar apps by allowing you to load your scripts' output into macOS native menubar.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/scgap6esrrggp49oy4tx.png)

# Setup
1. Install BitBar (https://getbitbar.com/)
2. Set plugin folder
3. Download an existing plugin
   OR 
   Create your own plugin (https://github.com/matryer/bitbar)

# Existing scripts (Plugins)
You can download existing plugins from the Bitbar plugins repo. They even created a custom browser protocol (url schema bitbar://) so you can easily install the plugins. Plugins are your regular .js, .php., .sh, ... files.

# Your own scripts
To create a plugin, just write an executable script that outputs to the standard output and put it in your BitBar plugin folder and make sure it's executable 

Here’s a JavaScript example demonstrating basic visalization syntax:
```javascript
#!/usr/bin/env /usr/local/bin/node
console.log(`🎩 Title`)
console.log(`---`) // separator
console.log(`🇭🇷 Menu item name | color=red `)
console.log(`--🐰 Submenu item | color=green`)
console.log(`Bitbar api docs | color=blue href=https://github.com/matryer/bitbar#plugin-api`)
```

![Bitbar basic example](https://dev-to-uploads.s3.amazonaws.com/i/w0f8ht4ss2x9rxddq7h2.png)

# Ideas
As you will see, there are a lot of plugins and if you need an inspiration browse the plugins repo. 
There are a lot of integrations with known tools: Infrastructure (AWS, DigitalOcean, Heroku), productivity tools (Jira), Version Control tools (Github, Bitbucket, GitLab), CIs (Jenkins, CircleCI), Error reporting tools (Sentry) and so on.
Other than that, there are plugins for Cryptocurrencies, finance, music, weather and many many more.

# What we used it for
We created a plugin for our internal time-tracking tool (Vremenco) and made it easy to track our work by enabling the interface in the menubar. Since we have an iOS department, we ended up using the native app. :)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m711m1kqq44dp307yjlt.png)

# Tips
- You can easily control the execution frequency (refresh rate) by naming your script file to match the time, e.g. test.1m.js which will run the script every 1 minute.
- use symlinks if you are actively working on your script
- there are some known issues, be aware

# Conclusion
If you need some info always to be visible or a click away, this tool will give you that. It almost effortlessly provides you an environment to run your scripts. You _do_ need to learn about formatting the output, but it is very easy and intuitive.

This is a quick and alternative way of building macOS menubar apps. You can also use Electron as another alternative method as opposed to writing native macOS apps which requires that specific stack knowledge.

What are your opinions? 
What script would be a great candidate for putting in menubar?