Skip to content

Instantly share code, notes, and snippets.

@dotaxis
Last active September 20, 2024 23:14
Show Gist options
  • Save dotaxis/1ad1c64baa7ad9c1dabcb255ea6257ae to your computer and use it in GitHub Desktop.
Save dotaxis/1ad1c64baa7ad9c1dabcb255ea6257ae to your computer and use it in GitHub Desktop.
Memoria Patcher for Linux
#!/bin/bash
echo "WARNING!"
echo "A Steam copy of FINAL FANTASY IX needs to be installed on this device!"
echo
echo "If you face issues with this installer, please pay us a visit on Discord:"
echo "https://discord.gg/tsunamods-community-277610501721030656"
echo "You can find me (Dot) in the #ff9-steamdeck channel!"
echo
echo "Press Enter to continue."
read
getSteamLibrary() {
local app_id="$1"
local path=$(
awk -v app_id="$app_id" '
/^[[:space:]]*"[0-9]+"$/ {
in_block = 1;
block = $0;
next;
}
in_block {
block = block "\n" $0;
if ($0 ~ /^\s*}/) {
in_block = 0;
if (block ~ app_id) {
match(block, /"path"\s+"([^"]+)"/, arr);
print arr[1];
exit;
}
}
}
' "${HOME}/.steam/root/steamapps/libraryfolders.vdf"
)
echo "$path"
}
downloadDependency() {
local XDG_CACHE_HOME="${XDG_CACHE_HOME:=${HOME}/.cache}"
local REPO=$1
local FILTER=$2
local RETURN_VARIABLE=$3
local RELEASE_URL=$(
curl -s https://api.github.com/repos/"$REPO"/releases/latest \
| grep "browser_download_url.$FILTER" \
| head -1 \
| cut -d : -f 2,3 \
| tr -d \")
local FILENAME="${XDG_CACHE_HOME}/$(basename "$RELEASE_URL")"
if [ -f "$FILENAME" ]; then
echo "$FILENAME is ready to be installed."
else
echo "$FILENAME not found. Downloading..."
curl -#SL -o $FILENAME $RELEASE_URL
fi
eval "${RETURN_VARIABLE}=\"$FILENAME\""
}
# Check for FF9
while true; do
if ! pgrep steam > /dev/null; then nohup steam &> /dev/null; fi
while ! pgrep steam > /dev/null; do sleep 1; done
GAMEPATH=$(LIBRARY=$(getSteamLibrary 377840) && [ -n "$LIBRARY" ] && echo "$LIBRARY/steamapps/common/FINAL FANTASY IX/" || echo "NONE")
echo -n "Checking if FF9 is installed... "
if [ "$GAMEPATH" = "NONE" ]; then
echo -e "\nNot found! Launching Steam to install."
nohup steam steam://install/377840 &> /dev/null &
read -p "Press Enter when FF9 is done installing."
killall -9 steam
while pgrep steam >/dev/null; do sleep 1; done
rm $HOME/.steam/steam/steamapps/libraryfolders.vdf &> /dev/null
rm $HOME/.steam/steam/config/libraryfolders.vdf &> /dev/null
else
echo "OK!"
echo "Found FF9 at $GAMEPATH!"
break
fi
done
echo
shopt -s expand_aliases
alias protontricks='flatpak run com.github.Matoking.protontricks'
alias protontricks-launch='flatpak run --command=protontricks-launch com.github.Matoking.protontricks'
echo "Installing Protontricks"
flatpak --system install com.github.Matoking.protontricks -y
flatpak override --user --filesystem=host com.github.Matoking.protontricks
echo
echo "Downloading Memoria Installer"
downloadDependency "Albeoris/Memoria" "*.exe" MEMORIA
echo
echo "Running Memoria Installer"
protontricks-launch --appid 377840 "$MEMORIA" "Z:$GAMEPATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment