Skip to content

Python script to place text notifications/messages in the Mac OS X menubar.

Notifications You must be signed in to change notification settings

alexglasser/menubarnotifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

MenubarNotifier
menubarnotifier.py

Alex Glasser
September 23, 2014

This is a simple script to display a message in the Mac OS X menubar using 
PyObjC. Make sure you have PyObjC installed - you can do this using MacPorts 
or Homebrew.

Call the script with the desired notification as the first and only argument:
$ ./menubarnotifier.py "Notification Text"

You may have to add executable permissions to the file first:
$ chmod +x ./menubarnotifier.py

This does use NSLog which writes to stderr by default. The way to bypass the 
logging is to redirect stderr to /dev/null with:
$ ./menubarnotifier.py "Notification Text" 2>/dev/null

You will also want to run this in the background so it does not require 
Ctrl+C to allow you to continue using your shell:
$ ./menubarnotifier.py "Notification Text" 2>/dev/null &

Highly recommended:
Open your ~/.bash_profile and add/rename the following function:

# MenubarNotifier function
mn () {
    /path/to/menubarnotifier.py "$1" 2>/dev/null &
}

Restart your Terminal. This will allow the script to be run like this:
$ mn "Notification Text"

...and will not require any redirection or the ampersand. 

Feel free to use this code for whatever you want. 

About

Python script to place text notifications/messages in the Mac OS X menubar.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages