protonfixes icon indicating copy to clipboard operation
protonfixes copied to clipboard

Add support for non-Steam games

Open daniel-j opened this issue 4 years ago • 3 comments

I have some non-Steam Windows games that I'd like to make fixes-scripts for, in case I lose the proton prefix for that game, or mess it up. It's also so that others can set up same game with fixes applied.

Right now I use protontricks to do this manually. It can search for non-Steam games by name (to get the generated appid).

Describe the solution you'd like I'd like that protonfixes detect what non-Steam game I'm launching and load a protonfixes script for it.

Describe alternatives you've considered Use the name/title of a game to identify it is the most straightforward solution, since non-Steam games don't get predictive appids. I am unsure if the code exists in Proton or protonfixes to get the name of the game today. Alternatively, an environment variable could be used in launch arguments. For example PROTONFIXES_GAME=Journey %command%. This env var could also be set to an appid to run a fix-script for a Steam game (for example if you got a game from GOG that's also on Steam).

daniel-j avatar Nov 22 '19 09:11 daniel-j

I tried to use a few non-steam games w/ protonfixes a while ago using following hack:

diff --git a/protonfixes/fix.py b/protonfixes/fix.py
index b026a31..30a4036 100755
--- a/protonfixes/fix.py
+++ b/protonfixes/fix.py
@@ -18,9 +18,12 @@ def game_id():
     """ Trys to return the game id from environment variables
     """
 
-    if 'SteamAppId' in os.environ:
+    # For non-steam games we only care about pfx and gamefix ids match
+    is_nonsteam = 'SteamAppId' in os.environ and os.environ['SteamAppId'] == '0'
+
+    if 'SteamAppId' in os.environ and not is_nonsteam:
         return os.environ['SteamAppId']
-    if 'SteamGameId' in os.environ:
+    if 'SteamGameId' in os.environ and not is_nonsteam:
         return os.environ['SteamGameId']
     if 'STEAM_COMPAT_DATA_PATH' in os.environ:
         return re.findall(r'\d+', os.environ['STEAM_COMPAT_DATA_PATH'])[-1]

It will use pfx ID for non-steam game, e.g. if you have .../compatdata/1234567890/ prefix, then the fix name should be 1234567890.py.

pchome avatar Nov 25 '19 20:11 pchome

But the prefix id is something the Steam client generates for a shortcut. It's not the same every time/for everyone.

daniel-j avatar Nov 30 '19 21:11 daniel-j

Well, I don't know how this IDs generated, I didn't dig a lot. But for two non-Steam games they was the same across sessions for the same user. So I decided to use them, because this matches protonfixes behaviour for Steam games.

If you want existing gamefix for your non-Steam game -- just symlink it to your localfixes directory. Or try to add something like

if 'PROTONFIXES_GAME' in os.environ:
   return os.environ['PROTONFIXES_GAME']
...

on top of this code block. Then use PROTONFIXES_GAME=12345 %command%. I doubt you want something like PROTONFIXES_GAME="Guacamelee! Super Turbo Championship Edition" %command%

pchome avatar Dec 01 '19 00:12 pchome