-- Compile with: osacompile -o "Weekly Command Center.app" "Weekly Command Center.applescript" on run set launchScript to "" try set launchScript to system attribute "WCC_LAUNCH_SCRIPT" -- Finder apps do not inherit exports from a Terminal window. if launchScript is "" then set launchScript to do shell script "/bin/launchctl getenv WCC_LAUNCH_SCRIPT || true" if launchScript is "" then set appPath to POSIX path of (path to me) set siblingScript to do shell script "/usr/bin/dirname " & quoted form of appPath set siblingScript to siblingScript & "/scripts/launch.sh" set bundledScript to appPath & "Contents/Resources/scripts/launch.sh" if my readableFile(siblingScript) then set launchScript to siblingScript else if my readableFile(bundledScript) then set launchScript to bundledScript else error "Cannot find scripts/launch.sh. Keep the scripts folder beside Weekly Command Center.app, or set WCC_LAUNCH_SCRIPT to your launch script." end if end if if not my readableFile(launchScript) then error "The launch script is missing or unreadable: " & launchScript -- Successful launches are silent. The script should start long-lived jobs in the background. do shell script "/bin/zsh " & quoted form of launchScript on error messageText display dialog messageText with title "Weekly Command Center" buttons {"OK"} default button "OK" with icon caution end try end run on readableFile(filePath) try do shell script "/bin/test -f " & quoted form of filePath & " && /bin/test -r " & quoted form of filePath return true on error return false end try end readableFile