Skip to content

Commit 4aaff22

Browse files
committed
Fix KeyError when setting UMU_ID from Steam client
- UMU clients will always set the WINEPREFIX and UMU_ID environment variables. However, setting a UMU_ID value from the Steam client's launch options to apply a specific fix will raise a KeyError because the Steam client does not set WINEPREFIX. To allow setting UMU_IDs in this case, instead of depending on WINEPREFIX being set in the environment, use Proton's environment
1 parent 3b2b959 commit 4aaff22

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

fix.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
from checks import run_checks
2222
from logger import log
2323

24+
try:
25+
import __main__ as protonmain
26+
except ImportError:
27+
log.warn('Unable to hook into Proton main script environment')
2428

2529

2630
@lru_cache
@@ -41,12 +45,14 @@ def get_game_id() -> str:
4145

4246

4347
@lru_cache
44-
def get_game_name() -> str:
48+
def get_game_name() -> str: #pylint: disable=R0914
4549
""" Trys to return the game name from environment variables
4650
"""
51+
pfx = protonmain.g_session.env.get('WINEPREFIX')
52+
4753
if os.environ.get('UMU_ID'):
48-
if os.path.isfile(os.environ['WINEPREFIX'] + '/game_title'):
49-
with open(os.environ['WINEPREFIX'] + '/game_title', 'r', encoding='utf-8') as file:
54+
if os.path.isfile(f'{pfx}/game_title'):
55+
with open(f'{pfx}/game_title', 'r', encoding='utf-8') as file:
5056
return file.readline()
5157

5258
if not check_internet():

0 commit comments

Comments
 (0)