Unfortunately is not matter of ‘Focus’ since: 1) is not active; and 2) I do get notifications if I invoke Display Notifications from the Script Debugger. But I do not get any notification when I run the same command from Terminal.
Any other idea?
Then execute the command again in the Script Editor (not Script Debugger) and see if the notification is displayed. If not, then check the notification setting of the Script Editor. It seems that osascript is running in its context and there are separate settings for notifications for each app.
Otherwise you could try the following again:
osascript <<EOF
display notification "Hello from me" with title "Hello"
delay .5
EOF
I was searching all over the internet trying to figure out why the osascript command wasn’t working. I had it embedded in a Python script that I was running via launchd on my MacBook to automate a task and trigger a notification every minute.
And this solution worked perfectly, i needed to run an osascript command in the script editor once to grant permission. This is a really silly mistake from apple if you ask me, the system should prompt for permission when you are trying to run it from the terminal. But well, im still new to programming so i dont know lol.
If you ever organize group work sessions over other channels (discord, etc) please let me know, I’m looking to join a team to collaborate and share what I’ve been learning.
I did have this working, but now it quit working. I haven’t used osascript for a few years and now I’m trying to use it in a small project. I followed the above and gone through several things to get it to work. But, I still can’t get notifications, just dialogs.
Permissions must always be granted to the process that ultimately executes the script. If osascript is run in Terminal, then Terminal must have permission to display notifications or run automations. If it is called from Script Editor, then it is Script Editor, and so on.
Also check whether a focus is preventing or filtering the display of notifications.
If the calling app is not signed or notarised (see SD Notary), the system may ignore the settings for displaying notifications.