Video

Your own sources on Mac: from the terminal to your menu bar

Your server reports a finished backup, a script a new version? Your own scripts and programs can send channelBar messages through the command-line tool or a webhook, and the newest one shows up in the menu bar right away. The video shows you how in just over two minutes.

In channelBar for macOS, messages don’t just come from feeds. Your own scripts and programs can send messages too, through the command-line tool or a webhook.

A channel for them

Create a separate channel for them. You’ll find the settings at the bottom of every channel’s menu, under “Settings…”, and the plus at the bottom left adds a new channel. Enter its name under “Identifier”, here “Alerts”. That’s the name your scripts use to address it later.

The “Standard” preset fits: it shows the newest message as text up in the menu bar, with a small triangle in front. Notification and sound are off with this preset; you change that under “Outputs”. You decide how the channel looks in the settings yourself, as a separate video shows. After “Create”, the channel first appears in gray up top, with its name in square brackets.

The command line

On the “Provider” page, add the “Command Line Application” with “Add Provider”. It’s switched on right away, and right below you see the matching command with its options. Without this provider, the channel accepts nothing from the command line.

You install the tool itself once, with Homebrew or an installer package for the Mac. The instructions are on channelbar.app.

One line is enough

In Terminal, one line is enough: channelbar set, the channel name and your message in quotes. It shows up in the menu bar right away.

With the --source option, you say where the message comes from; with --link, you attach an address. That’s how a script can announce a new version, for example, with a link to the page about it. With --open, you give the message an app or a command to start; if it has both, channelBar asks on click which one to open.

All messages in the menu

A click on the channel shows all messages. Point at one to see its source and its link next to it. A click on the message opens the link; if it has none, channelBar copies its text.

More ways

At the bottom of the menu, “Settings…” takes you back to the settings. Under “Add Provider”, you’ll find every way to send your own messages, among them “Apple Shortcuts”, “URL Scheme”, “File Watcher” and “MQTT”.

For servers too

The command-line tool is also available for Linux. A server can use it to tell you when its backup is done, for example. The message then arrives through “channelBar Cloud”, and there’s a separate video on that.

The webhook

For other programs, pick “HTTP Webhook” and switch it on; unlike the command line, it’s still off after you add it. Next to it, you see where the request goes and what it looks like: by default, a POST to port 8080 of this Mac, at the address /message/ followed by the channel name.

By default, channelBar only accepts requests from this Mac: the webhook server listens on localhost only, as the “Security Notice” next to it says. Under “API Key”, you can set a key; every request then has to send it in the X-API-Key header.

One call with curl

To try it out, curl is all you need. The message goes into the JSON field “text”; if you like, add “link”, “source” and other fields, just like on the command line. Any program that can call a web address can send its message the same way.

That’s how messages from your own scripts and programs land right in your menu bar.

← All posts