-- The main.scpt file is the entry point for the macOS app on run try -- display dialog "Welcome to the Example Bundle Simple App!" buttons {"OK"} default button "OK" -- Check if RUN_FROM_LAUNCHD is set as an environment variable. -- We use this env var check to prevent unintentional double-click launches. set reporoot to system attribute "RUN_FROM_LAUNCHD" if reporoot is "" then display dialog "This app is not designed to be launched by double-clicking. It should be run from its launchd agent." buttons {"OK"} default button "OK" with icon stop return end if -- Run the bundled shell script. set qScriptPath to quoted form of POSIX path of (path to resource "run.sh") do shell script qScriptPath return -- When an error occurs, display a dialog with the error message. on error errMsg number errNum display dialog "AppleScript error: " & errMsg & " (" & errNum & ")" buttons {"OK"} default button "OK" return end try end run