I have an AppleScript that does some copy/paste functions before my regular backups. At the very end of the script I call for a notification. I’m really not sure if it’s a script issue or a System Preferences/Notifications issue.
"/Users/homer/Library/Application Support/XMenu/Custom" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/XMenu Sync" with replacing
display notification "Completed Successfully!" with title "Pre Backup AppleScript"
delay 1```
"/Users/homer/Library/Application Support/PostboxApp/Profiles/lzdgaop0.default/abook.mab" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/Address Book Sync" with replacing
tell application id "com.apple.Finder" to duplicate file POSIX file ¬
"/Users/homer/Library/Application Support/PostboxApp/Profiles/lzdgaop0.default/history.mab" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/Address Book Sync" with replacing
tell application id "com.apple.Finder" to duplicate file POSIX file ¬
"/Users/homer/Library/Application Support/Firefox/Profiles/jla842kt.default-release/bookmarks.html" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/Firefox Bookmarks Sync" with replacing
tell application id "com.apple.Finder" to duplicate file POSIX file ¬
"/Users/homer/Library/Application Support/Firefox/Profiles/jla842kt.default-release/favicons.sqlite" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/Firefox Bookmarks Sync" with replacing
tell application id "com.apple.Finder" to duplicate file POSIX file ¬
"/Users/homer/Library/Application Support/Firefox/Profiles/jla842kt.default-release/places.sqlite" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/Firefox Bookmarks Sync" with replacing
tell application id "com.apple.Finder" to duplicate folder POSIX file ¬
"/Users/homer/Library/Application Support/ChronoSync/Tasks" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/Backup Scripts/ChronoSync Tasks" with replacing
tell application id "com.apple.Finder" to duplicate folder POSIX file ¬
"/Users/homer/Library/Application Support/XMenu/Custom" to the folder ¬
POSIX file "/Users/homer/Documents/MacBook Pro Specific/XMenu Sync" with replacing
display notification "Completed Successfully!" with title "Pre Backup AppleScript"
delay 1```
If I run the script from either Script Editor or Script Debugger, the notification is displayed. If I run the script as an Automator/Application, the notification is displayed. If I turn on the Script Editor menu and run it from there, the notification is displayed. I will look further into the notifications settings, although with the notification showing up in all the instances listed above, I think that finding anything there is unlikely.
For some mysterious reason, the notifications are once again working. I went to System Preferences/Notifications and deleted the entry that was there. Ran the script application and the notification came up. But, rather than dismissing it with a “click” (which I remember doing the first time it came up), I just let it sit there until it finally went away on its own. Now it’s working perfectly each time I run the script.
I just wanted to add to this that this is exactly what happened to me. I would run this simple line:
osascript -e 'display notification "The command finished" with title "Success"'
and could not get it to execute. No errors, just nothing. Tried it with multiple terminal apps, checked every single permission in settings.
I then ran the display notification "The command finished" with title "Success" portion in the script editor, and that worked. From then on, all subsequent calls with the osascript -e line work just fine. No idea why, but this may help others who experience this.