Trying to use Terminal for Display Notification

Hi all !
In macOS Sequoia, if I run in Script Editor:
display notification "Hi all"
it works as expected.

But if I use in Terminal:
osascript -e 'display notification "Hello from me" with title "Hello"'
is not working!!

But “display dialog” works perfectly:
osascript -e 'display dialog "Hello from me" with title "Hello"'

And also this is not working from the Script Editor:
do shell script "osascript -e 'run script \"display notification \\\"hello\\\"\"'"
I don’t understand why display notification cannot be triggered from Terminal anymore…
It is not ‘Focus’ that prevent this, since it is not activated.
Any Help ?
Thanks

Luciano

1 Like

The solution supplied by Dirk in the OP’s Late Night Software thread is to enable notification permissions for Script Editor.

Thanks a lot peavine.

I actually got help from an other forum. Here is what I did, and now it is working again !

I did run in Script Editor (and not in SD):
display notification "Hi all"

It actually asked me to allow Notifications for Script Editor!
And – as expected – I got the notification.

I then run in the Terminal (as Dirk suggested):
osascript <<EOF
display notification “Hello from me” with title “Hello”
delay .5
EOF

and it also worked!!!

Finally I run the code that initially for me was not working:
osascript -e 'display notification "Hello from me" with title "Hello"'

But NOW it worked!!!

You can see the full thread at:

Indeed. Which is a bit counterintuitive, since I was expecting (wrongly) that Terminal was requesting the permission to send notification …
Thanks again !

Me too! I expected to see the Terminal app in the Notifications Center, but it was actually Script Editor that needed the permission. After thinking about it, this makes sense.