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.
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
- Launch Power Manager.app
- Click Add… to create a new event
- Select the Run a script on-demand task
- Continue to the Script step
Copy and paste in the script in the Script to run field:
#!/bin/sh say "hello world" exit 0
- Continue passed the Constraints step onto the Why step.
- In the Why step name and add any optional notes about your new event.
- Continue to the final Confirm step.
- Add your new on-demand event.
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.