Notifications not shown from AppleScripts

BTT 5.802 and macOS 15.7.2

When I run applescripts from BTT, the notifications are not shown.

As example, the folllowing code is showing the notifications if it runs from script editor, but not if it runs from a BTT action:

tell application "BetterTouchTool" to display notification "Hello world" -->script editor icon
delay 1
tell application "BetterTouchTool" to display_notification "Hello Andreas" --> btt icon
delay 1
tell application "System Events" to display notification "Hello everybody"

I have the notifications allowed for BTT in the system settings.

I wonder if it is a bug from BTT or something wrong in my setup.

Make sure BTT is not the active app while the notifications are posted - otherwise with the default macOS settings they are posted but only show up if you open the control center sidebar

I find that the problem is only ocurring when the source type is an applescript from scpt file.

If I run the previous code when the source type is an applescript from scpt file, the only notification that is triggered when BTT is not the active app is "Hello Andreas".

If I run the same code when the source type is an applescript>Inline Text, the 3 notifications are shown.

So it seems that when external scpt files are called by BTT, the notifications from other apps are ignored.

Could you replicate that?

Is it possible to fix that?

that was one of the reasons the display_notification function was added, making the standard "display notification" functions work in this scenario is not possible as far as I know.

I can show any notification easily with the standard tell application "whatever" to display notification "whatever" function when running external applescripts from other apps (for example I can do it with Keyboard Maestro).

Maybe this was an old limitation that can be solved now…

@Andreas_Hegenberg If I use tell application "BetterTouchTool" to display_notification, how do I pass a shared secret from the script? Script Editor doesn’t allow me to append the shared_secret parameter in that case…

If I just call BTT as above, it displays a dialog allowing me to “Save New Shared Secret”, but I don’t really unterstand what this does. (Is it a one-time thing? Does it save my existing secret for the script or app that called BTT? Does it set a new secret?) I’d prefer to properly pass the secret from my AppleScript if possible…

Good point, that parameter was missing so it could never work with a shared secret. Should be resolved in 6.342 alpha

Great, it’s working now, thank you. It plays a sound with the notification though. I can suppress that through System Settings, but it would be good to know how to do that in AppleScript…? Unfortunately display_notification doesn’t seem to be documented online for AppleScript…

@Andreas_Hegenberg could you check this, and try to make BTT handle a standard "display notification" instruction from any "tell application 'appname' "?

@jordikt you can run standard display notification calls from BTT, BTT just forwards the Apple Script to the system. However there are various subtle details - most importantly macOS often doesn't show notifications if the app that is sending them is active. In that case they often directly go to the control center, so make sure BTT is not active when you try to send.
Also the "run in background" option might make them fail to show up.

@Andreas_Hegenberg please try this code:

tell application "BetterTouchTool" to display notification "1-Hello world"
delay 1
tell application "BetterTouchTool" to display_notification "2-Hello everybody" 
delay 1
tell application "System Events" to display notification "3-Goodbye"
delay 1
tell application "Finder" to display notification "4-Bye Bye"
return 1

If you run this code from applescript editor, you will see the four notifications as expected.

But if you run this applescript code from a BTT action, you will only see the 2nd notification. The other three notifications are never shown in the control center. It doesn't matter if the BTT action is background or not. It doesn't matter if BTT application is in foreground or in background.

As I have said previously, I am only experiencing this unexpected behaviour from applescripts executed in BTT. Other apps that can run applescripts (like Alfred or Keyboard Maestro) are showing the notifications as expected (and it doesn't matter if the apps are running in background or foreground).

I hope you can check and improve this limitation in BTT.

This issue has always been very frustrating to me.

Interesting, on my system they all showed (already dismissed the second one in the screenshot)

Could you check whether 6.346 improves the behavior for you? (uploading now)

v6.347 installed. The issue persists.

Are you running an external SCPT file?

The configuration of my action is:

ah no I tried inline. However for SCPT I also don't have any control, these are just passed to the system script runner, no BTT interaction with the script at all. It is however very possible that the system limits some UI interactions in this case - I cannot change that with the BTT setup where the Apple Scripts are handled by a separate BetterTouchToolAppleScriptRunner process.

If you need external files I would recommend to use this option instead of SCPT as it gives BTT full control over the script:

//edit: maybe I could change the scpt behavior so that BTT decompiles scpts by default, and apply the workarounds it already applies for inline scripts.

//edit2: 6.351 tries to do that, it decompiles the scpt file, patches the notification calls to work with the runner process and then runs it. I think the main problem is a macOS limitation that does not allow to whitelist runner processes like BTT uses for notification sending.

Yes, I need to run external files.

If I select the "External File (Create New)" or "External File(Choose Existing)" options as you recommand, the behaviour is the same: only the 2nd notification is shown.

But if I select "Inline Text" and paste the code, the behaviour is the same: only the 2nd notification is shown.

Version installed. Unfortunately the issue is not fixed.

Very respectfully, I think it is wrong to think that the limitation is in the macOS side.

As I said you previously, other apps are running the same external applescript showing the four notifications as expected.

BTT is also running all external applescripts without any limitation or restriction since I started using it years ago. The only issue I have always experienced is the "display notification problem".

Maybe the "problem" is something wrong configured in the "BetterTouchToolAppleScriptRunner process"?

unfortunately there is not much to configure. I just tried a few AI models to figure out s solution, but they come to the same conclusion, it seems to be a limitation related to xpc services running Apple Scripts (probably not intentional) because macOS doesn’t allow to whitelist them for notification sending. The other tools you mention most likely use a different system without XPC services for running Apple Script, but this setup is very fundamental to BTT‘s architecture (without it the whole BTT scripting interface would break) and can not really be changed. You could probably call the scripts through the osascript command line utility for basic usecases.

However why the inline approach doesn’t work for you is something I don’t understand, do the notifications also not show up in control center?

Ah I forgot to enable the new workaround introduced in 6.351. It should now be enabled by default in 6.352 (uploading)

Alternatively you can enable it on 6.351 via this terminal command:

defaults write com.hegenberg.BetterTouchTool BTTAppleScriptRewriteDisplayNotificationToBTT YES

6.352 also contains a workaround for making the notifications display while BTT is still the active app.

@Shnub I have added documentation for display_notification to

On 6.352 if you pass an empty string for sound name it will be silent

Thanks @Andreas_Hegenberg to improve this feature!!

I have installed the version 6.352 with very good results. I tell you the different behaviours I'm getting depending on different actions configurations:

CASE 1: Action "Run Applescript (async in background)" => "Source Type: Apple Script From SCPT File"

a) If I click the "Run Script" button inside BTT action, the four notifications are shown :white_check_mark:
b) If I trigger the keyboard shortcut with BTT editor opened, only the 2nd notification is shown :cross_mark:
c) If I trigger the keyboard shortcut with BTT editor closed, only the 2nd notification is shown :cross_mark:

CASE 2: Action "Run Applescript (blocking)" => "Source Type: Apple Script From SCPT File"

a) If I click the "Run Script" button inside BTT action, only the 2nd notification is shown :cross_mark:
b) If I trigger the keyboard shortcut with BTT editor opened, only the 2nd notification is shown :cross_mark:
c) If I trigger the keyboard shortcut with BTT editor closed, only the 2nd notification is shown :cross_mark:

CASE 3: Action "Run Applescript (async in background)" => "Source Type: Apple Script" => "Inline Text"

a) If I click the "Run Script" button inside BTT action, the four notifications are shown :white_check_mark:
b) If I trigger the keyboard shortcut with BTT editor opened, the four notifications are shown :white_check_mark:
c) If I trigger the keyboard shortcut with BTT editor closed, the four notifications are shown :white_check_mark:

CASE 4: Action "Run Applescript (async in background)" => "Source Type: Apple Script" => "External File (Choose Existing)"

a) If I click the "Run Script" button inside BTT action, the four notifications are shown :white_check_mark:
b) If I trigger the keyboard shortcut with BTT editor opened, the four notifications are shown :white_check_mark:
c) If I trigger the keyboard shortcut with BTT editor closed, the four notifications are shown :white_check_mark:

CASE 5: Action "Run Applescript (blocking)" => "Source Type: Apple Script" => "Inline Text"

a) If I click the "Run Script" button inside BTT action, the four notifications are shown :white_check_mark:
b) If I trigger the keyboard shortcut with BTT editor opened, the four notifications are shown :white_check_mark:
c) If I trigger the keyboard shortcut with BTT editor closed, the four notifications are shown :white_check_mark:

CASE 6: Action "Run Applescript (blocking)" => "Source Type: Apple Script" => "External File (Choose Existing)"

a) If I click the "Run Script" button inside BTT action, the four notifications are shown :white_check_mark:
b) If I trigger the keyboard shortcut with BTT editor opened, the four notifications are shown :white_check_mark:
c) If I trigger the keyboard shortcut with BTT editor closed, the four notifications are shown :white_check_mark:

Case 1 and 2 are weird because "Run Script" button is working as expected when the applescript is running in background, but the rest of options in both cases are not showing the four notifications.

Anyway now the notifications are working much better! :grinning_face:

thanks a lot for testing!

I'll patch cases 1 and 2 as well, I think I just missed one code path.

Just a note: what is now happening internally is that BTT replaces all display notification calls with its own display_notification calls. This makes it so the system doesn't need to whitelist the XPC helper process but just the BTT process - which works fine.