notifications – Compiled Javascript for Automation (JXA) script does not show applications

I wrote a small script to sync one folder to another as a Javascript for Automation script.

If I run it directly from terminal:

$ osascript -l JavaScript myscript.js

then it works as supposed – the referenced shell script is run, and then a dialog popup with the output of the shell script is shown, and then the notification is shown in the top right corner.

Now, I need this script to have full disk access to run it via launchd. For that, I compile the script into an application:

osacompile -l JavaScript -o myscript.js

Now, if I run the resultant app:


everything works (the app requests access to external volume, as should be), but unfortunately, the notification is not shown in the top right corner. It seems like macOS does not register the app for shown notifications (it does not appear in the notifications pane in System preferences).

How can I solve this bug with notifications? Thank you!

The myscript.js content:

const app = Application.currentApplication();
app.includeStandardAdditions = true;

console.log("Start sync-archive");
const home = app.systemAttribute("HOME");
const script = home + "/.launchd/sync-archive/";
const res = app.doShellScript("zsh " + script);

if (res.includes("success")) {
  app.displayNotification("completed successfully", {
    withTitle: "sync-archive",
  console.log("Finish sync-archive: success");
} else {
  app.displayAlert("sync-archive failed", {
    message: "Please see " + script + " and logfiles",
    as: "warning",
  console.log("Finish sync-archive: failure");

Author: Subham

Leave a Reply

Your email address will not be published. Required fields are marked *