Notification with Apple script doesn't work

The notification doesn't display if the script is running with BTT. If It's running with Script editor all work fine. I create a TouchBar button with Run Apple script.

	tell application "Finder"
		eject (every disk whose ejectable is true and local volume is true and free space is not equal to 0)
	end tell
	display notification with title "Disk ejected"
on error
	display notification with title "Error to Disk"
end try

Device information:

  • Type of Mac: MacBookPro14,2
  • macOS version: 14.3
  • BetterTouchTool version: 2.717

you need to use the blocking apple script action, not the one that's running in background (background scripts can not show any ui related stuff)

Tanks, It's possible to have more detail ? Because, I don't know what is the blocking apple script action.

If possible please post a screenshot on how you did configure it, then I can tell exactly what's wrong :slight_smile:

Great ! I found it :slight_smile:

I just had to uncheck "Run in Backgroung " in the panel to add Apple Script.

Thank you for your quick help

I'd like to bump this thread because I'm running into the same issue, however it's only when trying to trigger notifications using JXA instead of standard AppleScript.

As an example, here's a script that does work when executed:

tell application "Music"
		if loved of current track is true then
			set loved of current track to false
			set theTrack to (name of current track)
			set loveStatus to "♡"
			set loved of current track to true
			set theTrack to (name of current track)
			set loveStatus to "♥"
		end if
	end try
end tell
display notification with title "Music" subtitle loveStatus & " " & theTrack

I have a rather complex set of triggers to rate a song, however, which are written in JXA; here's my code for one that rates a song 3 stars and updates my Touch Bar UI:

var token = "<<my secret key>>";
var star_widgets = [

var Music = Application('Music');
var BetterTouchTool = Application('BetterTouchTool');
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var rating = 3;

if (Music.running()) {
    var t = setTrackRating(rating);
    display_rating_notification(rating, t);

function setTrackRating(r) {
    r = r * 20;
    var track = Music.currentTrack();
    track.rating = r;

function update_rating_widgets(r) {
    for (var i = 0; i < 5; i++) {
        if (i < r) {
            apply_rating_to_widget(star_widgets[i], 1);
        } else {
            apply_rating_to_widget(star_widgets[i], 0);

function apply_rating_to_widget(target, filled) {
    var star_type;
    if (filled) {
        star_type = "★";
    } else {
        star_type = "☆"
    BetterTouchTool.update_touch_bar_widget(target, {
        "text": star_type,
        "shared_secret": token

function display_rating_notification(r, name) {
    var r_string = "";
    for (var i = 0; i < 5; i++) {
        if (i < r) {
            r_string += "★";
        } else {
            r_string += "☆"
    app.displayNotification(r_string, {
        withTitle: "Music",
        subtitle: name
	return "★";

The script executes properly when run in the background, but if run in the foreground, BTT locks up. If I copy and paste the script into Script Editor, it executes properly with a notification.

Any thoughts?