Skip to content

Instantly share code, notes, and snippets.

@Sporif
Last active October 4, 2021 16:51
Show Gist options
  • Save Sporif/d788e61a994494f1c05954540a76f4f7 to your computer and use it in GitHub Desktop.
Save Sporif/d788e61a994494f1c05954540a76f4f7 to your computer and use it in GitHub Desktop.
A simple script that sets environment variables to allow launching applications using Proton's wine
#!/usr/bin/env bash
# A simple script that sets environment variables to allow launching applications using Proton's wine
# You can either source the script for use in the current shell, after which you can use wine commands as usual
# Or execute it with a program as the arguments e.g `protonenv winetricks` or `protonenv winecfg`
# Paths to check for Steam installation
STEAM_DIRS="
$HOME/.local/share/Steam
$HOME/.steam/steam
$HOME/.steam/root
"
# Check for default Steam library
for STEAM_DIR in ${STEAM_DIRS}; do
if [ -d "${STEAM_DIR}/steamapps" ]; then
break
else
unset STEAM_DIR
fi
done
if [ -z "${STEAM_DIR}" ]; then
echo "ERROR: No Steam path found!"
else
LIBRARY_DIRS="${STEAM_DIR}"
# Get non-default Steam library paths from libraryfolders.vdf
LIBRARY_DIRS="${LIBRARY_DIRS} $(grep -E "\"[0-9]{1,2}\"" "${STEAM_DIR}/steamapps/libraryfolders.vdf" \
| sed 's/\s*"[0-9]*"\s*"//' | sed 's/"$//')"
# Get Proton path
PROTON_DIR=$(find ${LIBRARY_DIRS} -maxdepth 3 -type d -iwholename '*/steamapps/common/Proton*' -print -quit)
if [ -z "${PROTON_DIR}" ]; then
echo "ERROR: Proton path not found!"
else
echo "Found Proton at ${PROTON_DIR}"
# Set the proton environment
echo "Setting env vars"
W="${PROTON_DIR}/dist"
export WINEVERPATH="${W}"
export PATH="${W}/bin${PATH:+:${PATH}}"
export WINESERVER="${W}/bin/wineserver"
export WINE="${W}/bin/wine"
export WINELOADER="${W}/bin/wine"
export WINEDLLPATH="${W}/lib64/wine:${W}/lib/wine"
export LD_LIBRARY_PATH="${W}/lib64:${W}/lib:$("${STEAM_DIR}/ubuntu12_32/steam-runtime/run.sh" --print-steam-runtime-library-paths)${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
fi
fi
# Don't pollute the environment in case this script is sourced
unset STEAM_DIRS STEAM_DIR LIBRARY_DIRS PROTON_DIRS PROTON_DIR
if [ -n "$*" ]; then
exec "${@}"
fi
Copy link

ghost commented Mar 5, 2020

Dear friend,

firstly I must thank you for this, is very cool.
Furthermore, I can't figure it out how to use it. I have already added to my path in usr/bin
then I add the template to Ksysguard.

I apologise, I am not an acceptable linux user.

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