2023-06-28 07:45:37 -04:00
#!/usr/bin/env osascript
2023-06-28 11:05:53 -04:00
on ExitWithMessage(message)
display dialog message
2023-08-03 16:39:17 -04:00
do shell script "sudo rm -rf \"" & binPath & "\""
2023-06-28 11:05:53 -04:00
error number -128
end ExitWithMessage
2023-08-03 20:03:29 -04:00
set installerChoices to {"Install Geode", "Uninstall Geode"}
set installerAnswer to choose from list installerChoices with title "Geode" with prompt "What do you want to do?" default items "Install Geode"
if installerAnswer is false then
2023-06-28 11:05:53 -04:00
ExitWithMessage ("Prompt cancelled.")
2023-08-03 20:03:29 -04:00
else
set installerAnswer to installerAnswer's item 1
end if
set tmpPath to POSIX path of "/tmp/"
set binPath to (tmpPath & "geode-install/")
tell application "System Events"
try
set libraryPath to POSIX path of (path to home folder from user domain)
set steamPath to (libraryPath & "/Library/Application Support/Steam/steamapps/common/Geometry Dash/")
2023-08-04 14:25:00 -04:00
display dialog "Steam path: " & steamPath
2023-08-03 20:03:29 -04:00
if exists folder steamPath then
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"} default location steamPath))
else
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"}))
end if
set gdPath to (gdPath & "/")
on error
ExitWithMessage ("Prompt cancelled.")
end try
set execPath to (gdPath & "Contents/MacOS/Geometry Dash")
set frameworkPath to (gdPath & "Contents/Frameworks/")
set fmodPath to "libfmod.dylib"
set fmodOriginalPath to "restore_fmod.dylib"
set geodePath to "Geode.dylib"
set bootstrapperPath to "GeodeBootstrapper.dylib"
set resourcesPath to "resources/"
set newGeodePath to "Contents/geode/"
set newResourcesPath to (newGeodePath & "resources/geode.loader/")
try
2023-06-28 11:05:53 -04:00
if not exists file execPath then
ExitWithMessage ("Not a valid Geometry Dash installation (executable missing): " & gdPath)
end if
if not exists file (frameworkPath & fmodPath) then
ExitWithMessage ("Not a valid Geometry Dash installation (fmod missing): " & gdPath)
end if
2023-08-03 20:03:29 -04:00
on error
ExitWithMessage ("Not a valid Geometry Dash installation: " & gdPath)
end try
end tell
if installerAnswer is "Install Geode" then
try
do shell script "mv -n \"" & (frameworkPath & fmodPath) & "\" \"" & (frameworkPath & fmodOriginalPath) & "\""
on error
ExitWithMessage ("Saving original fmod failed: " & (frameworkPath & fmodPath))
end try
try
do shell script "mv \"" & (binPath & geodePath) & "\" \"" & (frameworkPath & geodePath) & "\""
do shell script "mv \"" & (binPath & bootstrapperPath) & "\" \"" & (frameworkPath & bootstrapperPath) & "\""
do shell script "mv \"" & (binPath & fmodPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && chown -R $INSTALLER_USER \"" & frameworkPath & "\""
on error
ExitWithMessage ("Moving libraries failed: " & frameworkPath)
end try
try
do shell script "mkdir -p \"" & (gdPath & newResourcesPath) & "\""
do shell script "mv \"" & (binPath & resourcesPath) & "\"* \"" & (gdPath & newResourcesPath) & "\""
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && chown -R $INSTALLER_USER \"" & (gdPath & newGeodePath) & "\""
on error
ExitWithMessage ("Moving resources failed: " & (gdPath & newResourcesPath))
end try
2023-08-07 12:30:46 -04:00
do shell script "sudo xattr -dr com.apple.quarantine \"" & gdPath & "\""
2023-08-03 20:03:29 -04:00
else if installerAnswer is "Uninstall Geode" then
try
do shell script "rm \"" & (frameworkPath & geodePath) & "\""
do shell script "rm \"" & (frameworkPath & bootstrapperPath) & "\""
do shell script "rm \"" & (frameworkPath & fmodPath) & "\""
on error
ExitWithMessage ("Removing libraries failed: " & frameworkPath)
end try
try
do shell script "mv \"" & (frameworkPath & fmodOriginalPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
on error
ExitWithMessage ("Restoring original fmod failed: " & (frameworkPath & fmodPath))
end try
try
do shell script "rm -r \"" & (gdPath & newGeodePath) & "\""
on error
ExitWithMessage ("Removing geode folder failed: " & (gdPath & newGeodePath))
end try
end if
2023-06-28 11:05:53 -04:00
2023-08-03 16:39:17 -04:00
do shell script "sudo rm -rf \"" & binPath & "\""