Skip to content

Instantly share code, notes, and snippets.

@mibli
Created June 8, 2021 23:28
Show Gist options
  • Save mibli/e0bba23fbfe87e29e746ab70bdd6a577 to your computer and use it in GitHub Desktop.
Save mibli/e0bba23fbfe87e29e746ab70bdd6a577 to your computer and use it in GitHub Desktop.
proton-run
#!/bin/bash
die() {
echo "$@"
exit 1
}
library_paths=( /mdata/games/ /data/games /sdata/games )
case "$1" in
-l|list)
for path in "${library_paths[@]}"; do
ls "$path/steam/steamapps/common" 2>/dev/null | grep Proton
done
exit ;;
-h|--help|help) echo "$0 (list|<version> <appid> <executable>)"; exit ;;
*) ;;
esac
[ $# -ne 3 ] && die "Expected 3 arguments, got $#"
version="$1"
appid="$2"
executable="$3"
compat=
prefix=
proton=
for path in "${library_paths[@]}"; do
p="$path/steam/steamapps/compatdata/$appid"
if [ -d "$p" ]; then
install="$(realpath "$p/../../../")"
compat="$p"
prefix="$compat/pfx"
fi
p="$path/steam/steamapps/common/$version/proton"
if [ -f "$p" ]; then
proton="$p"
fi
done
[ -n "$compat" ] || die "Failed to find the compatdata dir"
[ -n "$proton" ] || die "Failed to find the proton"
cd "$prefix" || die "Failed to cd into $prefix"
echo "Prefix is '$prefix'"
STEAM_COMPAT_CLIENT_INSTALL_PATH="$install" \
STEAM_COMPAT_DATA_PATH="$compat" \
WINEPREFIX="$prefix" \
"$proton" run "$executable"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment