Skip to content

Instantly share code, notes, and snippets.

@dotaxis
Created June 8, 2024 14:54
Show Gist options
  • Save dotaxis/954e906ee03c9309b5518751ac4f5d3a to your computer and use it in GitHub Desktop.
Save dotaxis/954e906ee03c9309b5518751ac4f5d3a to your computer and use it in GitHub Desktop.
Wrapper for running HobbitInstaller for FF8 in Linux
#!/bin/bash
# Locate SteamLibrary containing app_id
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"
}
# Download from GitHub
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\""
}
FF8_DIR=$(LIBRARY=$(getSteamLibrary 39150) && [ -n "$LIBRARY" ] && echo "$LIBRARY/steamapps/common/FINAL FANTASY VIII" || echo "NONE")
if [ "$FF8_DIR" = "NONE" ]; then
echo "Error: Couldn't detect FF8 library."
exit 1
fi
shopt -s expand_aliases
if which protontricks &> /dev/null; then
echo "Native Protontricks already installed. Continuing."
else
echo "Installing Protontricks via flatpak"
alias protontricks='flatpak run com.github.Matoking.protontricks'
alias protontricks-launch='flatpak run --command=protontricks-launch com.github.Matoking.protontricks'
flatpak --system install com.github.Matoking.protontricks -y
flatpak override --user --filesystem=/run/media/mmcblk0p1 com.github.Matoking.protontricks
echo
fi
echo "Downloading HobbitInstaller"
downloadDependency "HobbitDur/HobbitInstaller" "*.zip" ZIPFILE
unzip -u "$ZIPFILE" -d "$FF8_DIR"
echo
echo "Launching HobbitInstaller"
cd "$FF8_DIR"
protontricks-launch --appid 39150 "HobbitInstaller.exe" &> /dev/null
cd -
echo
echo "Done! You can close this window now."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment