UWINE/gamelauncher_plugins.py
R1kaB3rN 066e869485
RFC: Rewrite gamelauncher in Python (#8)
- In its current form, executing the gamelauncher script can be tedious especially when not using a modern shell that supports auto completions. For instance:

$ WINEPREFIX=$HOME/Games/epic-games-store GAMEID=egs PROTONPATH=$HOME/.steam/steam/compatibilitytools.d/GE-Proton8-28 ./gamelauncher.sh $HOME/Games/epic-games-store/drive_c/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win32/EpicGamesLauncher.exe -opengl -SkipBuildPatchPrereq

- By rewriting the gamelauncher script in Python, we can support reading from a configuration file(s) instead which increases ease of use and provides better organization. This effectively results in this:

$ gamelauncher.py --config example.toml

- Additionally, due to the rich Python ecosystem, the rewrite leaves room for future features and formal testing if needed.
2024-02-09 19:21:10 -08:00

40 lines
1.3 KiB
Python

import os
from pathlib import Path
from typing import Dict, Set
def enable_steam_game_drive(env: Dict[str, str]):
"""Enable Steam Game Drive functionality.
Expects STEAM_COMPAT_INSTALL_PATH to be set
STEAM_RUNTIME_LIBRARY_PATH will not be set if the exe directory does not exist
"""
paths: Set[str] = set()
root: Path = Path("/")
# Check for mount points going up toward the root
# NOTE: Subvolumes can be mount points
for path in Path(env["STEAM_COMPAT_INSTALL_PATH"]).parents:
if path.is_mount() and path != root:
if env["STEAM_COMPAT_LIBRARY_PATHS"]:
env["STEAM_COMPAT_LIBRARY_PATHS"] = (
env["STEAM_COMPAT_LIBRARY_PATHS"] + ":" + path.as_posix()
)
else:
env["STEAM_COMPAT_LIBRARY_PATHS"] = path.as_posix()
break
if "LD_LIBRARY_PATH" in os.environ:
paths.add(Path(os.environ["LD_LIBRARY_PATH"]).as_posix())
if env["STEAM_COMPAT_INSTALL_PATH"]:
paths.add(env["STEAM_COMPAT_INSTALL_PATH"])
# Hard code for now because these paths seem to be pretty standard
# This way we avoid shelling to ldconfig
paths.add("/usr/lib")
paths.add("/usr/lib32")
env["STEAM_RUNTIME_LIBRARY_PATH"] = ":".join(list(paths))
return env