Change icon of notification when using osascript -e "display notification"

Actually, this is possible.

Just save your script as an application and then switch the applet.icns file within the application's Contents/Resources folder for the icon you want.

Any notifications sent from your script will use that icon.


You cannot. This is simply not a macOS feature exposed to AppleScript.

If you need a custom icon, consider using a pop-up "dialog" rather than a Notification Center pop-up. With timeouts and buttons you can recreate much of the functionality, though not the integration nor aesthetics.

In `display dialog', if you wish to use the standard icons: 0, 1, or 2 (stop, note, or caution), perhaps don't have osascript be the program that displays the icon. Finder, for example:

osascript -e 'tell application "Finder"' -e 'activate' -e 'display dialog \
"this is the note icon." with icon note' -e 'end tell'

or without the tell application… you may use an icon of your choice by referencing it directly, e.g. the Terminal app's icon:

osascript -e 'display dialog "Terminal icon" with icon alias \
"Macintosh HD:Applications:Utilities:Terminal.app:Contents:Resources:Terminal.icns"'

I'm not sure what you mean by, "the only way to change its icon is from an external bundle. Is there any way to make osascript -e display what I want."  What, precisely, do you want? What have you tried?

Here's the display dialog section from Apple's documentation.

Tags:

Applescript