From abd3a9d49618fa7ca9b40491022375d38435d09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathis=20Dr=C3=B6ge?= Date: Tue, 2 Aug 2022 18:42:00 +0200 Subject: [PATCH] [core] Save path resolution: Fallback to reading wine prefix from env vars This is mainly something for Heroic, since we don't touch config.ini --- legendary/core.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/legendary/core.py b/legendary/core.py index ed2ca91..30f6877 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -863,6 +863,18 @@ class LegendaryCore: wine_pfx = self.lgd.config.get('default.env', 'WINEPREFIX', fallback=None) wine_pfx = self.lgd.config.get('default', 'wine_prefix', fallback=wine_pfx) + # If we still didn't find anything, try to read the prefix from the environment variables of this process + if not wine_pfx and sys_platform == 'darwin': + cx_bottle = os.getenv('CX_BOTTLE') + if cx_bottle and mac_is_valid_bottle(cx_bottle): + wine_pfx = mac_get_bottle_path(cx_bottle) + + if not wine_pfx: + proton_pfx = os.getenv('STEAM_COMPAT_DATA_PATH') + if proton_pfx: + wine_pfx = f'{proton_pfx}/pfx' + wine_pfx = os.getenv('WINEPREFIX', wine_pfx) + # if all else fails, use the WINE default if not wine_pfx: wine_pfx = os.path.expanduser('~/.wine')