Skip to content

Instantly share code, notes, and snippets.

@AnonymerNiklasistanonym
Last active December 23, 2021 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AnonymerNiklasistanonym/a6fcc96af437dbe5dd67faa3551267f4 to your computer and use it in GitHub Desktop.
Save AnonymerNiklasistanonym/a6fcc96af437dbe5dd67faa3551267f4 to your computer and use it in GitHub Desktop.
Helping script that automatically installs the Media Foundation workaround for Wine (https://github.com/z0z0z/mf-install) to the latest Proton Version
#!/usr/bin/env bash
# If the following variables are not empty there will be no command line dialog
# for them
CUSTOM_STEAM_ID="" # "922500"
CUSTOM_STEAM_NAME="Custom" # "KIllLaKIllIF"
CUSTOM_PROTON_VERSION="" # "- Experimental"
CUSTOM_STEAM_GAME_DATA_LOCATION=""
ASK_FOR_CONFIRMATION="" # Anything other than empty string disables confirmation
# Stop script if a step fails
set -e
STEAM_APPS_DIRECTORY="$HOME/.local/share/Steam/steamapps"
STEAM_APPS_DIRECTORY_COMMON="$STEAM_APPS_DIRECTORY/common"
if ! [ -d "$STEAM_APPS_DIRECTORY" ]; then
echo "Error: Steam apps directory location '$STEAM_APPS_DIRECTORY' was not found. Can not continue."
exit 1
fi
if ! [ -d "$STEAM_APPS_DIRECTORY_COMMON" ]; then
echo "Error: Steam apps directory common location '$STEAM_APPS_DIRECTORY_COMMON' was not found. Can not continue."
exit 1
fi
# Select which game should be updated if not already selected
STEAM_ID=-1
STEAM_NAME="None"
if [ -z "$CUSTOM_STEAM_ID" ]
then
PS3='Enter/select your Steam game id: (if not listed enter Steam ID) '
options=("Gris" "PummelParty")
select opt in "${options[@]}"
do
case $opt in
"Gris") STEAM_ID=683320; STEAM_NAME="Gris"; break ;;
"PummelParty") STEAM_ID=880940; STEAM_NAME="PummelParty" break ;;
*) STEAM_ID=$REPLY; STEAM_NAME="Custom" break ;;
esac
done
else
echo "> \$CUSTOM_STEAM_ID ($CUSTOM_STEAM_ID, $CUSTOM_STEAM_NAME) was found"
STEAM_ID=$CUSTOM_STEAM_ID; STEAM_NAME="$CUSTOM_STEAM_NAME";
fi
# Select the path where the game data is located
GAME_DATA_LOCATION="$STEAM_APPS_DIRECTORY/compatdata/$STEAM_ID"
if [ -z "$CUSTOM_STEAM_GAME_DATA_LOCATION" ]
then
PS3='Enter/select where your Steam game is located: (if not listed enter Steam game location) '
options=("(default) '$STEAM_APPS_DIRECTORY/compatdata/$STEAM_ID'")
select opt in "${options[@]}"
do
case $opt in
"${options[0]}") break ;;
*) GAME_DATA_LOCATION=$REPLY; break ;;
esac
done
else
echo "> \$CUSTOM_STEAM_GAME_DATA_LOCATION ('$CUSTOM_STEAM_GAME_DATA_LOCATION') was found"
GAME_DATA_LOCATION=$CUSTOM_STEAM_GAME_DATA_LOCATION
fi
if ! [ -d "$GAME_DATA_LOCATION" ]; then
echo "Error: Steam game data location '$GAME_DATA_LOCATION' was not found. Can not continue."
exit 1
fi
# Ask for specific proton version
PROTON=""
if [ -z "$CUSTOM_PROTON_VERSION" ]
then
proton_versions=($( find "$STEAM_APPS_DIRECTORY_COMMON" -maxdepth 1 -regex ".*Proton.**" -type d -printf '%f\n' ))
proton_versions=(${proton_versions[@]//Proton*/})
echo "Select the correct Proton version: "
select proton_version in "${proton_versions[@]}"
do
proton_version_index=$REPLY
proton_version_index=$((proton_version_index - 1))
PROTON="$STEAM_APPS_DIRECTORY_COMMON/Proton ${proton_versions[$proton_version_index]}"
break
done
else
PROTON="$STEAM_APPS_DIRECTORY_COMMON/Proton ${CUSTOM_PROTON_VERSION}"
fi
if ! [ -d "$PROTON" ]; then
echo "Error: Proton directory '$PROTON' was not found. Can not continue."
exit 1
fi
# -----------------------------------------------------------------------
# The important part [Variables] (begin)
# -----------------------------------------------------------------------
export WINEPREFIX="$GAME_DATA_LOCATION/pfx"
export PROTON="$PROTON"
echo "MAKE SURE THAT ALL PATHS ARE ABSOLUTE AND NOT RELATIVE!"
echo "STEAM_ID: '$STEAM_ID' ($STEAM_NAME)"
echo "WINEPREFIX: '$WINEPREFIX' (exists)"
echo "PROTON: '$PROTON' (exists)"
# -----------------------------------------------------------------------
# The important part [Variables] (end)
# -----------------------------------------------------------------------
# Ask if the critical execution should be started
if [ -z "$ASK_FOR_CONFIRMATION" ]
then
echo "Are you sure to continue with the selected values?"
select yn in "Yes" "No"
do
case $yn in
"Yes" ) break;;
"No" ) exit 0;;
*) exit 0;;
esac
done
fi
# -----------------------------------------------------------------------
# The important part [mf-install] (begin)
# -----------------------------------------------------------------------
rm -rf mf-install
git clone --depth=1 https://github.com/z0z0z/mf-install.git
cd mf-install
./mf-install.sh -proton
cd ..
# -----------------------------------------------------------------------
# The important part [mf-install] (end)
# -----------------------------------------------------------------------
@Syncrossus
Copy link

WINEPREFIX may be incorrect if you install your games on a different hard drive from the drive where Steam is installed. Proton will be installed on the same drive as Steam, e.g. /home/syncrossus/.local/share/Steam/steamapps/common/Proton 4.11 in my case, whereas GRIS's compatdata is on your games drive, e.g. /run/media/syncrossus/GAMEDRIVE/Software/steamapps/compatdata/683320/pfx in my case.

@AnonymerNiklasistanonym
Copy link
Author

AnonymerNiklasistanonym commented May 2, 2020

@Syncrossus Thanks for the feedback - the script should now be able to deal with that by letting you specify the game data location (either with a variable in the script at the top [CUSTOM_STEAM_GAME_DATA_LOCATION="/run/media/syncrossus/GAMEDRIVE/Software/steamapps/compatdata/683320"] or using the command line input during the execution).
I also added the option to select a specific installed Proton version if this would ever be a problem.
I hope it still works :D

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