Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Last active March 21, 2024 13:34
Show Gist options
  • Save thingsiplay/3a933f557277906dc6b0e03ec8df5dbd to your computer and use it in GitHub Desktop.
Save thingsiplay/3a933f557277906dc6b0e03ec8df5dbd to your computer and use it in GitHub Desktop.
Proton script
#!/bin/sh
# Execute Windows programs with Proton from Steams installation folder, without
# starting Steam client.
#
# 1. Create a directory for Proton environment to run in. As an example make a
# folder "proton" in your home directory. This folder must exist in order
# to make Proton work.
#
# 2. Point the variable "env_dir" in this script to that folder or...
#
# 3. ... alternatively set the environmenal variable "$PROTONPREFIX" to this
# folder before running the script. It works similar to the "$WINEPREFIX"
# from WINE and will have higher priority over "env_dir".
#
# 4. Look in your Steam installation folder at "steamapps/common/" folder for
# available Proton versions. Pick one and point the script variable
# "proton_version" to this that folder name, in example "Proton 3.16".
# Note: You have to download a Proton version from Steam first, if none is
# there yet.
#
# 5. Or alternatively set the environmental variable "$PROTONVERSION" to that
# folder name of Proton version before running the script. It has higher
# priority over script variable "proton_version".
#
# 6. Optionally install/copy this script in a directory that is in your $PATH,
# so you can run it easily from any place. Or set the default interpreter
# for .exe files to this script.
#
# Usage:
# proton program.exe
#
# or:
# export PROTONPREFIX="$HOME/proton_316"
# export PROTONVERSION="Proton 3.16"
# proton program.exe
# Folder name of the Proton version found under "steamapps/common/".
# proton_version="Proton - Experimental"
# proton_version="Proton 3.16"
proton_version="Proton - Experimental"
# Path to installation directory of Steam.
# Alternate path: "$HOME/.steam/steam"
client_dir="$HOME/.local/share/Steam"
# Default data folder for Proton/WINE environment. Folder must exist.
# If the environmental variable PROTONPREFIX is set, it will overwrite env_dir.
env_dir=$HOME/proton
# Proton modes to run
# run = start target app
# waitforexitandrun = wait for wineserver to shut down
# getcompatpath = linux -> windows path
# getnativepath = windows -> linux path
mode=run
# ENVIRONMENTAL VARIABLES
if [ -n "${PROTONPREFIX+1}" ]
then
env_dir=$PROTONPREFIX
fi
if [ -n "${PROTONVERSION+1}" ]
then
proton_version=$PROTONVERSION
fi
# EXECUTE
export STEAM_COMPAT_CLIENT_INSTALL_PATH=$client_dir
export STEAM_COMPAT_DATA_PATH=$env_dir
"$client_dir/steamapps/common/$proton_version/proton" $mode $*
@prateekmedia
Copy link

Thanks the above guide worked with experimental proton.

@brunoais
Copy link

Thank you for the script.
I picked it up and made it more automatic in case you are running the script for a steam game (so you can play the steam game without steam). And also other welcome automation.
https://gist.github.com/brunoais/575db9912368124d3223784afe20158c
Feel free to incorporate what you like into your script.

@thingsiplay
Copy link
Author

@brunoais
Interesting modification. There are some features I had in mind too. Multiple directories as fallback, log file, auto create dir and such. For the end user it is probably easier to use, if they don't edit the script. But it might be more complicated for the beginner, if they want edit it. At some point, I was thinking about going in a similar direction. But I am personally happy with the current state of the script. It is simple and easy to understand and everyone can adapt to their needs. I won't make such changes yet.

But it is always good to have alternate versions, so thank you for sharing too.

@brunoais
Copy link

Yep. It's a good reasoning. Ty for the feedback.

@thingsiplay
Copy link
Author

Just a heads up for anyone wanting to use this script. This is no longer tested with modern versions of Proton. But there is a fork that is enhanced and maintained by brunoais.

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