Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Last active March 21, 2024 13:34
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • 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

thingsiplay commented Jul 5, 2021

Added a new environmental variable, that is seemingly required with the newer version of Proton. Overall the structure of the variables changed, so it is easier to change proton version. I just tested a single application under Manjaro/Arch with current Proton - Experimental version being 6.3-2.

**A FEW HOURS LATER **

Introduction of new environmental variables PROTONPREFIX to control "env_dir" and PROTONVERSION to control "proton_version" without editing the script itself. Just set them as environmental variables before running the script. Works similar to WINEPREFIX from WINE itself.

@prateekmedia
Copy link

Can we get a video tutorial on how to set it up.

@thingsiplay
Copy link
Author

@prateekmedia

Can we get a video tutorial on how to set it up.

I never did any video tutorial, so for now don't know how to do all this stuff. Someday I may start doing video tutorials. But it is very easy and you don't need to do much:

  • What you basically do is just download the script, give it executable permission (or also called the executable bit) and create a folder named "proton" in your home directory. Then you should be able to run Windows programs by just typing proton myprogram.exe in the command in the terminal.

This script is very barebones and was created for people who know about commandline and stuff. The comments in the script basically tells you everything to know.

@prateekmedia
Copy link

prateekmedia commented Jul 12, 2021

I was having trouble running with it, I am on Manjaro kde with manually installation of proton-ge.

It is giving me python errors at line number something, with an error message when I run it.

Do I need to do any additional steps with it?

@thingsiplay
Copy link
Author

Normally not, but depends on what you do. I have Manjaro with KDE installed too (but use Qtile anyway). I never tried it out with GE version of Proton and did not a manual installation of it. The way I do (and other people where it worked) is to install a regular Proton version through Steam.
You have Steam installed right? Because the path of this script requires Steam and I never tried it without. Or your installation path of Steam is somewhere else maybe, then you would need to change the path in the script. Another question thing. If you use proton-ge, then you probably need to change the variable "proton_version", because the default expects "Proton - Experimental" version.

What error message do you get?

@prateekmedia
Copy link

I will try again with normal proton experimental, and yes manjaro comes preinstalled with Steam, so I have it.

@thingsiplay
Copy link
Author

You can use any other Proton version too (at least those installed from Steam, not sure otherwise). Look in your "steamapps/common/" in your Steam directory for any folder that starts with "Proton". In example if you have "Proton 3.16", then you can change the variable in the script from

proton_version="Proton - Experimental" to `proton_version="Proton 3.16" and it would use that instead.

You could try to move or copy the proton-ge folder into the "steamapps/common/" directory and change the variable to proton_version="proton-ge" (if that is the folder name of it). I hope this all is not not too confusing to you. Actually it is very simple and easy, but explaining it here makes it look confusing. The good thing is, Steam does not need to run when this script works and you can still make use of Proton.

@prateekmedia
Copy link

Can you please see and check the below error with proton-ge. which is installed in usr/share instead of local/share

File "/usr/share/steam/compatibilitytools.d/proton-ge-custom/proton", line 1326, in <module>
    if "link2ea" in str(sys.argv[2]):
IndexError: list index out of range

Also I see proton in steamapps-common path, there are only my installed games and no folder with proton name. I don't know if proton is even installed here, I have selected it in steam steam apps settings.

@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