Skip to content

Instantly share code, notes, and snippets.

@RedL0tus
Created October 1, 2021 05:50
Show Gist options
  • Save RedL0tus/0b1622958354204b3e4e6628d9c7d55e to your computer and use it in GitHub Desktop.
Save RedL0tus/0b1622958354204b3e4e6628d9c7d55e to your computer and use it in GitHub Desktop.
AppleScript to create an application bundle for ICS-51 MARS
set UnixPath to POSIX path of (path to me as text)
set jarPath to UnixPath & "mars.jar"
set iconPath to UnixPath & "/Contents/Resources/applet.icns"
set runMars to UnixPath & "runMars"
set unameM to do shell script "uname -m"
set unameA to do shell script "uname -a"
# Detect architecture
if (unameM contains "x86_64") then
if (unameA contains "ARM64") then
set jdkArch to "aarch64"
else
set jdkArch to "x86_64"
end if
else if (unameM contains "arm") then
set jdkArch to "aarch64"
else
set jdkArch to "x86_64"
end if
# Get path to bundled JDK
set javaHome to UnixPath & "jdk-17-" & jdkArch & "/Contents/Home"
set javaBinPath to javaHome & "/bin"
set javaBin to javaBinPath & "/java"
# Generate command
set command to "JAVA_HOME=\"" & javaHome & "\" "
set command to command & "PATH=\"" & javaBinPath & ":${PATH}\" "
set command to command & (quoted form of javaBin) & " "
set command to command & "-Xdock:name=\"ICS-51 MARS\" "
set command to command & "-Xdock:icon=" & (quoted form of iconPath) & " "
set command to command & "-jar " & (quoted form of jarPath)
do shell script command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment