#!/bin/sh
#
# TimeAlbumPro .app launcher.
#
# Architecture-agnostic shell launcher that execs the JRE bundled inside the
# .app (Contents/bin, populated from the hosted stripped JRE). Each
# arch-specific bundle ships a matching JRE (x64 or aarch64), so this single
# script boots natively on both Intel and Apple Silicon without requiring
# Rosetta. Replaces the former x86_64-only native libapplauncher stub, which
# forced the aarch64 bundle through Rosetta and prevented startup on Apple
# Silicon machines without it.
#
DIR="$(cd "$(dirname "$0")/.." && pwd)"
#
# Strip the download quarantine flag from the whole bundle before launching.
# The bundled JRE (Contents/bin/java + its dylibs) is Developer-ID signed by
# Temurin but NOT notarized. On Apple Silicon a quarantined, un-notarized
# binary that this script execs is SIGKILLed by the kernel ("Killed: 9") even
# after the user approves the Gatekeeper prompt -- that approval covers the
# bundle, not bin/java exec'd as a child process. Clearing com.apple.quarantine
# lets the signed JRE start. Best-effort: needs write access to the bundle
# (true under ~/Downloads or /Applications); a no-op once already cleared.
/usr/bin/xattr -dr com.apple.quarantine "$(cd "$DIR/.." && pwd)" 2>/dev/null || true
exec "$DIR/bin/java" \
  -Xdock:name=TimeAlbumPro \
  -Xdock:icon="$DIR/Resources/TimeAlbumPro.icns" \
  --add-exports java.desktop/com.apple.eawt=ALL-UNNAMED \
  -Xmx1024m \
  -jar "$DIR/Java/TimeAlbumProMac.jar" "$@"
