Skip to content

Instantly share code, notes, and snippets.

Created November 30, 2009 11:47
Show Gist options
  • Save rubiojr/245402 to your computer and use it in GitHub Desktop.
Save rubiojr/245402 to your computer and use it in GitHub Desktop.
MacRuby StatusBar Application
# Initialize the stuff
# We build the status bar item menu
def setupMenu
menu =
menu.initWithTitle 'FooApp'
mi =
mi.title = 'Hellow from MacRuby!'
mi.action = 'sayHello:' = self
menu.addItem mi
mi =
mi.title = 'Quit'
mi.action = 'quit:' = self
menu.addItem mi
# Init the status bar
def initStatusBar(menu)
status_bar = NSStatusBar.systemStatusBar
status_item = status_bar.statusItemWithLength(NSVariableStatusItemLength)
status_item.setMenu menu
img = 'macruby_logo.png'
# Menu Item Actions
def sayHello(sender)
alert =
alert.messageText = 'This is MacRuby Status Bar Application'
alert.informativeText = 'Cool, huh?'
alert.alertStyle = NSInformationalAlertStyle
response = alert.runModal
def quit(sender)
app = NSApplication.sharedApplication
# Rock'n Roll
app = NSApplication.sharedApplication
# Create the status bar item, add the menu and set the image
Copy link

Just in case somebody is wondering add: framework 'AppKit' tu run it
The icon will be blank unless you name some pic on that directory macruby_logo.png

Thanks for the gist

Copy link

ghost commented Jul 18, 2014

you attr_acessor my love

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment