Skip to content

Instantly share code, notes, and snippets.

@NeoTheFox
Last active February 3, 2026 11:43
Show Gist options
  • Select an option

  • Save NeoTheFox/cd80be9c34a0a3b0455050e823d78b60 to your computer and use it in GitHub Desktop.

Select an option

Save NeoTheFox/cd80be9c34a0a3b0455050e823d78b60 to your computer and use it in GitHub Desktop.
Link Steam's Proton prefixes by name for ease of use
#!/usr/bin/env bash
help() {
echo NAME
echo " compatdata.sh - create \"by-game\" symlink folder for every compatdata folder on this machine"
echo
echo SYNOPSIS
echo " compatdata.sh [-h] [-p]"
echo
echo OPTIONS
echo " -p Use protontricks to find all steam and non-steam prefixes"
echo " -h Print this help"
exit 0
}
while getopts ":hp" o; do
case "${o}" in
h)
help
;;
p)
export USE_PROTONTRICKS=1
;;
*)
help
;;
esac
done
shift $((OPTIND - 1))
mapfile -t compatdata_array < <(find / -type d -path "*/steamapps/compatdata" 2>/dev/null)
declare -A protontricks_names
function get_protontricks_names() {
while read -r game; do
local ID="$(echo $game | cut -d ' ' -f 1)"
local NAME="$(echo $game | cut -d ' ' -f 2-)"
protontricks_names+=(["$ID"]="$NAME")
done < <(protontricks -l | awk '/\([0-9]+\)/ { match($0, /\(([0-9]+)\)/, arr); appid = arr[1]; gsub(/ *\([^)]+\) */, "", $0); print appid " " $0 }')
}
[ "$USE_PROTONTRICKS" = "1" ] && get_protontricks_names
function get_name() {
if [ "$USE_PROTONTRICKS" = "1" ]; then
echo ${protontricks_names["$1"]}
else
curl -s "https://store.steampowered.com/api/appdetails?appids=$1" | jq -r '.[].data.name'
fi
}
for dir in "${compatdata_array[@]}"; do
echo "Found: $dir"
[ -d "$dir/by-game" ] || mkdir "$dir/by-game" || exit 1
mapfile -t pfx_array < <(find $dir -type d -maxdepth 1 -mindepth 1 2>/dev/null)
for pfx in "${pfx_array[@]}"; do
APPID=$(basename $pfx)
[ "$APPID" = "0" ] && continue
[ "$APPID" = "by-game" ] && continue
APPNAME=$(get_name $APPID)
[ "$APPNAME" = "null" ] && continue
[ "$APPNAME" = "" ] && continue
echo $APPID → $APPNAME
[ ! -d "$dir/by-game/$APPNAME" ] && ln -s "$pfx" "$dir/by-game/$APPNAME"
done
done
@NeoTheFox

NeoTheFox commented Dec 18, 2025 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment