Is there an easy way I can add custom icons to the menu bar status area? Ideally something like Growl (e.g., where you can just execute a command) but instead of notifications, just renders icons in the menu bar.

I'm mainly looking to draw numbers that I'd use to alert me of various things. For example, I can configure my email client to run a command/AppleScript to update the numbers when an certain kind of email arrives.

Something like this:



I would suggest starting with this thread, which describes using Cocoa Objective-C calls from within AppleScript. There is an example Xcode project here.

And Launch is a complete application written in AppleScript that functionally does this. Its Xcode project file is here.

The basic premise is to generate NSMenuItem instances and add them to the system's NSStatusBar:

set statusMenu to (NSMenu's alloc)'s initWithTitle_("Launch")
-- (build and do stuff with the statusMenu here)
set sysStatusBar to NSStatusBar's systemStatusBar
set statusItem to sysStatusBar's statusItemWithLength_(32)
tell statusItem to setMenu_(statusMenu)
tell statusItem to setHighlightMode_(1)
set menuImage to NSImage's imageNamed_("icon.png")
tell statusItem to setImage_(menuImage)

AppleScript excerpt from Launch's source code, Copyright © Lee Hanken

  • Links are missing now in 2018 – davidfrancis Jan 9 '18 at 12:34

Okay, I have made an app for this. It is on GitHub: 0942v8653/ScriptableStatusBar. Just keep the app running and use the sbar tool to set and remove items.

As the readme says:

sbar set face 😃 'Bye!:sbar remove face'

Creates a face in the status bar. The menu will have an option Bye! that runs sbar remove face getting rid of the menu it creates.

You can download a compiled version from https://github.com/0942v8653/ScriptableStatusBar/releases.

  • Nice, but why do You register to all distributed notifications instead of the one with name: "io.github.0942v8653.ScriptableStatusBar"? – Mateusz Szlosek Nov 4 '14 at 14:45
  • @MateuszSzlosek Good question. Will fix later :P – 0942v8653 Nov 4 '14 at 14:58
  • 1
    @MateuszSzlosek Fixed. – 0942v8653 Nov 4 '14 at 17:33
  • Your app's functionality seems to be very similar to "BitBar" (mentioned above); while yours features an icon (not sure if BitBar does), the other allows nearly any scripting language (with std-out) to very easily display its output in the right-hand menu bar. I use that to "osascript" an apple script that "returns" the current number of workspace I'm on (like in former OS versions). Scripts are simply placed into a plugin folder & EXTRA! part of names (e.g. xx.3s.sh => 3 seconds) specifies repetition intervals. VERY useful for status displaying !!! – clemsam lang Dec 4 '18 at 8:51

You can also use RubyCocoa:

require "osx/cocoa"
include OSX

app = NSApplication.sharedApplication
statusitem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength)

Another option is to use Rumps, a Python library that uses the Obj-C classes and functions.



Yes, you can create a Cocoa app for this purpose in Xcode. No, you cannot do it with applescript.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .