Notifications aren’t available in version of OS X older than 10.8/Mountain
notify() on these systems will
silently do nothing.
notify allows you to post notifications via OS X’s
Notification Center at any time, not just at the end of your script.
Furthermore, it uses your workflow’s icon, not Alfred’s.
Post notifications via the OS X Notification Center. This feature is only available on Mountain Lion (10.8) and later. It will silently fail on older systems.
The main API is a single function,
It works by copying a simple application to your workflow’s data directory. It replaces the application’s icon with your workflow’s icon and then calls the application to post notifications.
convert_image(inpath, outpath, size)¶
Convert an image file using sips.
RuntimeError– Raised if sips exits with non-zero status.
Extract Notify.app from the workflow to data directory.
Changes the bundle ID of the installed app and gives it the workflow’s icon.
Return logger for this module.
Returns: Logger for this module. Return type: logging.Logger
Return path to icon file in installed Notify.app.
Returns: Path to applet.icns within the app bundle. Return type: unicode
Return path to notifier applet executable.
Returns: Path to Notify.app applet executable. Return type: unicode
notify(title=u'', text=u'', sound=None)¶
Post notification via Notify.app helper.
- title (str, optional) – Notification title.
- text (str, optional) – Notification body text.
- sound (str, optional) – Name of sound to play.
ValueError– Raised if both title and text are empty.
True if notification was posted, else False.
Convert PNG file to ICNS using iconutil.
Create an iconset from the source PNG file. Generate PNG files in each size required by OS X, then call iconutil to turn them into a single ICNS file.
RuntimeError– Raised if iconutil or sips fail.
Coerce sound to valid sound name.
Returns None for invalid sounds. Sound names can be found in System Preferences > Sound > Sound Effects.
Parameters: sound (str) – Name of system sound. Returns: Proper name of sound or None. Return type: str