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 $*
@thingsiplay
Copy link
Author

The script expects the Proton version to be installed where the steamapps/common path is. If there is no proton there, then you need to download it with Steam first. Also, if the proton is in any other directory than steamapps/common, then it will will not work if the script is not changed. Because it was never designed to be used otherwise and without testing I can't just predict. Also did you do this from the README of Proton-GE? - https://github.com/GloriousEggroll/proton-ge-custom#notes

PLEASE NOTE: There are prerequisites for using this version of proton:

You must have wine installed on your system
You must have winetricks installed on your system
You must have wine dependencies installed on your system. See https://www.gloriouseggroll.tv/how-to-get-out-of-wine-dependency-hell/
You must have vulkan gpu drivers/packages installed properly on your system. See https://github.com/lutris/docs/blob/master/InstallingDrivers.md

As I don't have wine and winetricks installed and don't plan to, cannot test proton-ge for now and my assistant is very limited.
But at least the regular proton version should work for you. If there is no Proton folder in the steamapps/common directory, then you have to download it in Steam client with the GUI first.

  1. https://i.imgur.com/lsKu8RJ.png - Enable Proton - Experimental first.
  2. Download a Windows only game, so Steam is forced to download Proton once. Choose a small game to test for.
  3. Check if the folder "Proton - Experimental" is found under steamapps/common.
  4. Create a folder "proton" in your home directory of Linux (under "~/").
  5. Try the unmodified version of proton script (I name the executable file just "proton") first, which expects these folders and Proton version: ./proton myprogram.exe

Hopefully this will work.

@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