Add a per game user_settings.py
Add a per game user_settings.py
Allow a prefix directory to have an individual user_settings.py to change runtime config options
Non-Steam games are not able to use %command% launch options.
There is no way to enable or disable options like DXVK for non-Steam games without making it global.
This work could be rendered pointless if the Steam bug is fixed.
https://github.com/ValveSoftware/steam-for-linux/issues/6046
It would be better to just fix the Steam bug than add this complication.
But good news, user_settings.py is actually just a python script. You could add some logic there checking SteamGameId (or some other logic) in the environment and do the right thing for your configuration.
It would be better to just fix the Steam bug than add this complication.
Was going to basically say the same thing. Most people can't use computers let along work with Python programming language lol Linux users or not. Plus, its a royal pain to go and edit a bunch of scripts. It would be better if they added in a script section to each game properties at that point. That's going too far.
[Or better yet, add in a WYSIWYG editor that creates the script for people.] Complications =)
[Or a tab to dl approved files for the game that others have done, etc]. The list just keeps going....
Just have a option in the game link properties (and for shortcut of non-steam-games) that says _"Open Steamplay Config File for this game"_ and it opens it in default text editor with a DEFAULT configuration file that has most things people might want but with # in front with comment sections, if you can read you can understand it, remove has to enable option...
Just save this config file in the games exe folder and maybe backed up somewhere else in steam folder cache.
Just made a wrapper for proton to workaround in a simple manner:
First move your real proton executable to proton.ori; In my case:
mv "~/giochi/Steam/steamapps/common/Proton 4.11/proton" "~/giochi/Steam/steamapps/common/Proton 4.11/proton.ori"
...Next, create another proton executable, the wrapper:
touch "~/giochi/Steam/steamapps/common/Proton 4.11/proton" ; chmod +x "~/giochi/Steam/steamapps/common/Proton 4.11/proton"
Last step: paste the followong inside it:
#!/bin/bash
delim="protonhack=1" #<- use this at the beginning of your launch options
proton_exe=\'"${0%/*}"/"proton.ori"\'
full="$@"
if echo $full | grep "$delim" ; then
#Extract the proton args given by steam, leave out our additions:
bare=$(awk -F$delim '{ for(i=1;i<=1;i++) print $i }' <<< "$full")
#Strip it from the steam complete command line:
stripped=${full#$bare}
#Replace %command% with bare proton command:
final=$(echo $stripped | sed "s|%command%|$proton_exe $bare|")
else
#passthrough:
final="$proton_exe $full"
fi
#Start it:
echo running: "$final"
sh -c "$final"
Now, to enable the wrapper logic, YOU HAVE to puth protonhack=1 as the very first env var in your launch options.
Example:
protonhack=1 LD_LIBRARY_PATH=/my/native/lib.so my-precommand %command& mypostcommands
...seems to work good here.
Theres no need to have a user_settings.py file for each game.
It would be great if proton user_settings.py support global and per-game settings. Apended. Like DXVK_CONFIG_FILE.
But instead of pointing to games exe:
[example.exe]
Points to steam game id:
[302010]
"WINEDLLOVERRIDE": "..."
@Lepidos Yeah, that's basically what I suggested back in August. It's just a Python file, so you can do whatever you like, including set overrides only for certain appids.
Proton user_settings.py file just says:
_#This settings here will be applied to all games running on this proton version_
...
It could have instructions/example on how to apply settings to a single game.
_#This settings only apply to single game/steamappid running on this proton version_
...
@Lepidos
Unofficial example:
user_settings = {
"ABC": "CD",
"CDE": "DEF",
}
import os
if 'SteamAppId' in os.environ:
#This settings only apply to single game/steamappid running on this proton version
if os.environ['SteamAppId'] == '12345':
user_settings["AC"] = "test1"
user_settings["ABC"] = "test2"
del user_settings["CDE"]
For test file named ssets.py, just to check if it work:
$ python
>>> import ssets
>>> ssets.user_settings
{'ABC': 'CD', 'CDE': 'DEF'}
$ SteamAppId=12345 python
>>> import ssets
>>> ssets.user_settings
{'ABC': 'test2', 'AC': 'test1'}
It works @aeikum ! :+1:
@Lepidos
Unofficial example:user_settings = { "ABC": "CD", "CDE": "DEF", } import os if 'SteamAppId' in os.environ: #This settings only apply to single game/steamappid running on this proton version if os.environ['SteamAppId'] == '12345': user_settings["AC"] = "test1" user_settings["ABC"] = "test2" del user_settings["CDE"]For test file named
ssets.py, just to check if it work:
$ python>>> import ssets >>> ssets.user_settings {'ABC': 'CD', 'CDE': 'DEF'}
$ SteamAppId=12345 python>>> import ssets >>> ssets.user_settings {'ABC': 'test2', 'AC': 'test1'}
Could you better explain HOW this works. I'm trying to get this to work for a non-steam game in proton, and I don't understand how any of this is supposed to work.
@Inotamira I don't know how it works, never wrote any python code before. But it does.
Can you try it with a steam game? Have you only tried with non-steamappid?
@Inotamira I don't know how it works, never wrote any python code before. But it does.
Can you try it with a steam game? Or have you only tried with non-steamappid?
There's no use for it for regular steam games, as all of this can be set using launch options. So no, only with the non-steam game which I can't set launch options for due to a bug.
I cannot confirm it, because I have not tested this with non-steamappid, nor I have used proton for non-steam games.
I cannot confirm it, because I have not tested this with non-steamappid, nor I have used proton for non-steam games.
From what I can tell after looking through proton itself, there's a couple of potential options, but I don't really understand Python that well, I'm coming at this as someone that understands Java, C++ and C#, so the formatting isn't the same at all. I've tried searching for the PID of the game itself using it's name, but I don't understand how to pass variables in Python properly, so while I'm sure I've caught the PID correctly, I don't know how to pass it on so it then triggers the settings for the non steam game.
To explain what I've tried so far, this is where I'm at
import subprocess
pid = int(subprocess.run(["pidof", "-s", "yourprocess"], capture_output=True).stdout)
if pid != 0:
user_settings = {
"DXVK_HUD": "fps",
"PROTON_USE_D9VK": "1",
}
Edit: the problem is the game will never exist before the settings are loaded, so I need a different variable.
Edit 2: So, there is a gameID assigned to the non-steam proton games, however, I don't know how to pass this into user_settings as a clause.
Okay, I have this MOSTLY working using two python files since the main user settings file doesn't seem to like to do work without breaking things.
user_settings.py
from game import settings
user_settings = settings
game.py
import os
ID = "None"
os.environ["SteamAppId"] = ID
if ID == "33554432":
settings = {
"DXVK_HUD": "fps",
"PROTON_USE_D9VK": "1",
}
The only thing I can't figure out, and the method here doesn't work at all, is how to latch onto the AppID.
Thanks to the boys over at reddit, I have a working method, and it only takes the one user_settings.py
import os
ID = os.path.basename(os.environ['STEAM_COMPAT_DATA_PATH'])
if ID == 'nameofcompatdatafolder':
settings = {
"DXVK_HUD": "fps",
"PROTON_USE_D9VK": "1",
}
else
if ID == 'nameofcompatdatafolder':
settings = {
other settings
}
else
if ID == 'nameofcompatdatafolder':
settings = {
other settings
}
else
you get the idea
user_settings = settings
for however many games you need, simply replace "nameofcompatdatafolder" with the number for your particular non-steam game, and you can place settings to your hearts content.
The user script does not get executed if you run proton via lutris or outside of steam I've noticed. Anyone else notice that?
@jarrard lutris uses its own wine configurations. To see them use the command:
lutris -d lutris:rungame/\
Except I'm running games as a wine environment with steams own proton. In saying that if you use the proton script in terminal to run things it also will ignore the configuration user file!!
Seems like a slight design oversight if you ask me, basically that user settings file is only grabbed if the game or app is run within steam client itself which is a tad annoying.
The path to user_settings.py is determined from the path used to invoke the proton script at runtime, see the assignment to user_settings_file in the Proton class's constructor. It's possible the way you're invoking the script causes an invalid path there. You could add some logging and try to find what's going wrong.
There is user_settings.py in the proton dist folder, then you have the prefix path. Are you saying that user_settings.py should be somewhere in the prefix folder when invoking proton that way?
anybody have a example to change the path of steam logs save for a different place, thanks
@jomarocas It is hard-coded to put logs in your home directory. You can change this by editing the proton script manually, but note your changes will be overwritten every time Proton updates and you'll have to edit the script each time.
so is just adding at the end of user_settings.py:
import os
if os.environ['STEAM_COMPAT_APP_ID'] == '221380':
user_settings['PROTON_USE_WINED3D'] = '1'
for example to enable wined3d only for Age of Empires.
I tested it and this way I can play two different games that needed one this config on and the other off, AoE II HD and GTA:SA, it is off by default but AOE needs it on in my system, then is just a matter of knowing each game APPID and to test which options work better.
Most helpful comment
@Lepidos
Unofficial example:
For test file named
ssets.py, just to check if it work:$ python$ SteamAppId=12345 python