
Sep 04, '12 07:30:00AM • Contributed by: Sesquipedalian
To set this up, simply do the following:
- Download and install the action.
- Create a new workflow in Automator containing only the Display Notification Center Alert action.
- In the variables section at the bottom of the workflow construction area in Automator's window, create three variables named
title
,subtitle
, andmessage
. - Give
message
a default value like "Notification sent." You can leave the default values other two blank. - Drag each variable to its corresponding field in the Display Notification Center Alert action.
- Save the workflow as Display Notification.wflow. A good place to save it is in ~/Library/Workflows (create the folder if necessary).
Now you can display a notification from the command line using the following command:
automator -D title='Title text' -D subtitle='Subtitle text' -D message='Message text' ~/Library/Workflows/'Display Notification.wflow'
To display notifications from AppleScripts, paste the following handler into your script, and call it using the form notify("Notification title", "Notification subtitle", "Notification message")
on notify(title, subtitle, message) if title as text is not "" then set title to " -D title=" & quoted form of (title as text) if subtitle as text is not "" then set subtitle to " -D subtitle=" & quoted form of (subtitle as text) if message as text is not "" then set message to " -D message=" & quoted form of (message as text) do shell script "automator" & title & subtitle & message & " ~/Library/Workflows/Display Notification.wflow" end notify