How to Run a Script from a Menu Item

Running a script from a menu bar item in Mac OS X is a great time saver. The menu bar is always available and easy to access. In this recipe we will create a menu item that triggers a shell script, all using Power Manager.

Running a script from a menu bar item in Mac OS X is a great time saver. The menu bar is always available and easy to access. In this recipe we will create a menu item that triggers a shell script, all using Power Manager.

Use Power Manager to run a script from the menu bar

Use Power Manager to run a script from the menu bar

In this recipe, the script will speak the words “hello world” using the command line tool say. You can embed any script you need performing. Power Manager supports any scripting language that can be called through the command line; these include bash, perl, php, python, ruby, and sh.

Create a Script On-Demand Event

  1. Launch Power Manager.app

  2. Click Add… to create a new event

TODO

Click Add… to create a new Power Manager event
  1. Select the Run a script on-demand task

TODO

Select the "Run script on-demand" task
  1. Continue to the Script step

  2. Copy and paste in the script in the Script to run field:

    #!/bin/sh
    
    say "hello world"
    
    exit 0
    

Paste in or type the script to run

Paste in or type the script to run
  1. Continue passed the Constraints step onto the Why step.

Continue passed the Constraints step

Continue passed the Constraints step
  1. In the Why step name and add any optional notes about your new event.

Name the new event and add optional notes

Name the new event and add optional notes
  1. Continue to the final Confirm step.

Confirm the event can be created

Confirm the event can be created
  1. Add your new on-demand event.

The event is created and ready for use

The event is created and ready for use

Your new event is ready to use immediately. The event has no associated schedule, so will only be triggered on-demand. You can trigger this event and its script through the Power Manager menu bar item, with the command line tool pmctl, or using your iOS device using Power Manager Remote.