MenuBarTrigger, a menubar utility for macOS admins

What does it do? MenuBarTrigger is a command-line utility that presents a menubar popover while simultaneously executing a shell command. The popover is a locally hosted webview. You can give MenuBarTrigger more than one web view and command to present, in which case it will move on to the next pair once the previous command finishes executing.

If the web view content has form input elements, eg. a checkbox, placed within the <form></form> tags, MenuBarTrigger can send the input value to standard output.

Each webview/command pair can have an icon allocated to it, so that the menubar icon changes as MenuBarTrigger progresses along the webview/command chain.

How exactly is it used?Below is the output of Trigger’s –help flag.

How does one get it? MenuBarTrigger is an open-source utility.

You can also get the latest prebuilt .app here.

Usage:

MenuBarTrigger.app/Contents/MacOS/MenuBarTrigger webview1 command1 webview2 command2 ... [OPTIONS]

WEBVIEW

The local HTML file or HTML string to display -f, –file OR -html, –html 

COMMAND

The command to execute. Command can be a shell command or a jamf binary command.

Example shell commands: 

‘sleep 5’

‘/tmp/a_script.sh’

“/usr/sbin/installer -package ‘/tmp/CocoaDialog v2.1.1.pkg’ -target /”

Note the single quotes to wrap around the filename with spaces.

Accepted jamf commands: All jamf verbs, although be warned that MenuBarTrigger has only been tested with jamf binary versions 9.61 – 9.97, so far. Note: MenuBarTrigger assumes that the binary is in /usr/local/bin/jamf. Specify fullpath if you relocated the binary. MenuBarTrigger needs to be run as root to run jamf commands.

Example jamf commands:

“policy -trigger ‘microsoft office'”

“policy -trigger vlc”

“recon”

There is one special MenuBarTrigger commands: wait

wait displays the webView until a particular link on the presented HTML.

MenuBarTrigger.app/Contents/MacOS/MenuBarTrigger WEBVIEW wait

What occurs once the link is clicked depends on the url:

  • A link to “next”, eg. <a href="http://next">NEXT</a>, makes MenuBarTrigger proceed to the next web view/command pair.
  • A link to “formParse”, eg. <a href="http://formParse">Submit</a>, will inspect any form values and return the results to stdout. before proceeding to the next web view/command pair.
  • A link to “quit”, eg. <a href="http://quit">Done</a>, terminates MenuBarTrigger. Be sure to add http:// in the link URL (required by macOS 10.12.4+)

COMMAND –icon 

Changes the menubar icon at the same time as the command is being run. Icon image file should be .png format and 16x16px in size.

COMMAND,NAME

If an output file is specified (see ‘-o, –output’ option below), all named commands have their stdout and success status written to this file. A command is named by appending a comma followed by the name in quotations. eg. “policy -trigger mcafee”,”McAfee Security Agent”

OPTIONS

–icon Sets menubar icon. Icon file should be .png format and 16×16 pixels in size. If this option is not set then the MenuBarTrigger icon is displayed instead.

-h, –height Height, in pixels, of content window. Must be within the minimum and maximum height of the content window. The range for this display is 20 – 701 pixels. Default height is 420px.

-w, –width Width, in pixels, of content window. Must be within the minimum and maximum width of the content window. The range for this display is 20 – 801 pixels. Default width is 420px.

EXAMPLES

/usr/local/MenuBarTrigger.app/Contents/MacOS/MenuBarTrigger --file /tmp/o365_installation_progress.html "policy -trigger o365 --icon /tmp/o365-icon.png" --width 325 --height 190
/usr/local/MenuBarTrigger.app/Contents/MacOS/MenuBarTrigger --file /tmp/zoom_installation_progress.html "policy -trigger zoom --icon /tmp/zoom-icon.png" --icon /tmp/setup-icon.png

Leave a Reply

Your email address will not be published.