"display notification" via BBEdit script menu

Hi, not sure whether it was possible in the past, but I can’t get BBEdit to display a notification via its script menu.

tell application "BBEdit"
	display alert "Test" -- works
	display dialog "Test" -- works
	display notification "Test" -- doesn't work
end tell

Already tried different settings in System Preferences > Notifications.

I could send the notification via do shell script "osascript -e " & quoted form of "display notification \"Test\"" but I’m curious what’s going on.

BBEdit 14.6.3
macOS 12.6.3 (ARM64E)

If you move the notification line out of the BBEdit tell, it works.

Thanks. Already tried that before creating the thread, it doesn’t work over here.

Also restarted the mac. And reached out to BBEdit support who showed me this link `display notification` works from AppleScript Editor but not when exported as Application - Ask Different. I don’t create threads easily, before doing that I try everything I can think of. In this case I’m out of ideas (and again, I’m actually not sure whether it was possible to use display notification via BBEdit’s script menu in the past).

BBEdit can display notifications for many things. Number of find/change from a search comes to mind.

Do those display for you?

1 Like

Yes, BBEdit’s own notifications are displayed:


We can identify each AppleScript runtime name by using simple AppleScript.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
set procInfo to current application's NSProcessInfo's processInfo()
set aName to procInfo's processName() as string
display dialog aName

By running this code from BBEdit’s Script Menu gaves us “BBScriptRunnerXPCService”.

スクリーンショット 2023-02-17 13.34.32

BBEdit seems to execute AppleScript by using other process in XPC service.
XPC service can not display such a notification UI.

So, BBEdit can not display notification messages from AppleScript.

You can display noftification dialog from BBEdit’s Script Menu by using other AppleScript Runtime.

For example…

do shell script "osascript -e 'display notification \"message from BBEdit\"'"

This AppleScript can display notification message because we changed AppleScript runtime program to /usr/bin/osascript.

Though we can select various way to execute AppleScript, /usr/bin/osascript will be the most simple way.

1 Like

Thanks a lot! This will be very useful to figure out what’s going wrong in similar situations.

As mentioned previously I reached out to BBEdit support before I created this thread. As far as I know (i.e. what I read over the years) BBEdit is one of the most scriptable apps around. Makes me wonder why they didn’t know that BBEdit can not display notifications via AppleScript.

So now I’ll simply use …

… to display notifications via BBEdit’s script menu.

Thanks again!

BBEdit will handle display notification in the future:

We’ve made a change for an upcoming update to handle the “display notification” event in-app, which should restore the expected behavior.


1 Like