SkillAgentSearch skills...

Menubarnotifier

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

Install / Use

/learn @alexglasser/Menubarnotifier
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.

Related Skills

View on GitHub
GitHub Stars16
CategoryDevelopment
Updated1y ago
Forks0

Languages

Python

Security Score

60/100

Audited on Jan 8, 2025

No findings