diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-07-03 10:35:37 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-07-03 10:35:37 +0300 |
| commit | 32b248f845281e5deacc5beddd3cc5cd08ab2469 (patch) | |
| tree | df090ad5b2962ab39913c002d6ba5fce1df8952f | |
| parent | 862b3156f7e6b19af570e7bcaaaf52614d0672be (diff) | |
| download | fungus-launcher-32b248f845281e5deacc5beddd3cc5cd08ab2469.tar.gz fungus-launcher-32b248f845281e5deacc5beddd3cc5cd08ab2469.tar.xz | |
handle multiple versions of steamrt
| -rw-r--r-- | fungus/run_manager.py | 25 | ||||
| -rw-r--r-- | fungus/settings_dialog.py | 37 | ||||
| -rw-r--r-- | fungus/umu_manager.py | 53 |
3 files changed, 98 insertions, 17 deletions
diff --git a/fungus/run_manager.py b/fungus/run_manager.py index 258d636..5d8aaaa 100644 --- a/fungus/run_manager.py +++ b/fungus/run_manager.py @@ -30,9 +30,7 @@ from fungus.game_model import Game, load_games_json, save_games_json from fungus.path_manager import PathManager from fungus.utils import has_proton_installed, is_executable_in_whitelist from fungus.dialogs import SandboxWarningDialog, SteamRuntimeWarningDialog - -# Path to the UMU Steam Runtime (used by umu-run) -UMU_STEAMRT_DIR = os.path.expanduser("~/.local/share/umu/steamrt3") +from fungus.umu_manager import proton_to_steamrt_variant compatibility_dir = os.path.expanduser("~/.local/share/Steam/compatibilitytools.d") os.makedirs(compatibility_dir, exist_ok=True) @@ -120,11 +118,14 @@ class FungusRun: os.environ["__VK_LAYER_NV_OPTIMUS"] = "NVIDIA_only" os.environ["__GLX_VENDOR_LIBRARY_NAME"] = "nvidia" - # Set environment variables from game properties + # Resolve the effective runner once — used for runtime check and env vars + proton_dir = self.game.runner or "" + + # Set environment variables for UMU-Launcher os.environ["GAMEID"] = self.game.protonfix or self.game.gameid or "" os.environ["WINEPREFIX"] = self.game.prefix or "" - if self.game.runner: - os.environ["PROTONPATH"] = self.game.runner + if proton_dir: + os.environ["PROTONPATH"] = proton_dir self.start_time = time.time() @@ -136,13 +137,16 @@ class FungusRun: ): os.environ["PROTONFIXES_DISABLE"] = "1" - # Validate that the UMU Steam Runtime is available - if not os.path.isdir(UMU_STEAMRT_DIR): + # Validate that the correct Steam Runtime is available for this Proton + steamrt_dir = os.path.expanduser( + f"~/.local/share/umu/{proton_to_steamrt_variant(proton_dir)}" + ) + if not os.path.isdir(steamrt_dir): self.close_splash_window() self.show_error_dialog_steam_runtime() # Validate that the selected Proton directory exists - protonpath = os.environ.get("PROTONPATH") + protonpath = proton_dir if protonpath: protonpath_path = Path(share_dir) / "Steam/compatibilitytools.d" / protonpath if not protonpath_path.is_dir(): @@ -602,11 +606,10 @@ class FungusRun: return env_from_file def load_config(self): - """Load discrete-GPU, default-runner, and game-directories from config.""" + """Load discrete-GPU and game-directories from config.""" cfg = ConfigManager() self.discrete_gpu = cfg.get_bool("discrete-gpu", False) - self.default_runner = cfg.get("default-runner", "") self.game_directories = cfg.get("game-directories", "").strip() def _watchdog_loop(self): diff --git a/fungus/settings_dialog.py b/fungus/settings_dialog.py index 58f7f84..fcaae39 100644 --- a/fungus/settings_dialog.py +++ b/fungus/settings_dialog.py @@ -24,6 +24,7 @@ from fungus.umu_manager import ( get_installed_umu_version, get_latest_umu_version, get_steamrt_last_check, + proton_to_steamrt_variant, save_steamrt_last_check, update_steam_runtime, ) @@ -152,6 +153,13 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): self.label_umu_runtime_status.set_max_width_chars(20) self.label_umu_runtime_status.set_ellipsize(Pango.EllipsizeMode.END) + self.label_umu_runtime_variant = Gtk.Label(label="Expected: steamrt3") + self.label_umu_runtime_variant.set_halign(Gtk.Align.START) + self.label_umu_runtime_variant.set_margin_start(10) + self.label_umu_runtime_variant.set_max_width_chars(20) + self.label_umu_runtime_variant.set_ellipsize(Pango.EllipsizeMode.END) + self.label_umu_runtime_variant.set_sensitive(False) # greyed out until runner selected + self.button_umu_runtime = Gtk.Button(label="Update Runtime") self.button_umu_runtime.set_image( Gtk.Image.new_from_icon_name("system-run-symbolic", Gtk.IconSize.BUTTON)) @@ -311,10 +319,11 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): self.label_umu_runtime_last.set_ellipsize(Pango.EllipsizeMode.END) grid_umu.attach(self.label_umu_runtime, 0, 5, 1, 1) - grid_umu.attach(self.label_umu_runtime_status, 0, 6, 1, 1) - grid_umu.attach(self.label_umu_runtime_last, 0, 7, 1, 1) - grid_umu.attach(self.button_umu_runtime, 0, 8, 1, 1) - grid_umu.attach(self.progress_umu_runtime, 0, 9, 2, 1) + grid_umu.attach(self.label_umu_runtime_variant, 0, 6, 1, 1) + grid_umu.attach(self.label_umu_runtime_status, 0, 7, 1, 1) + grid_umu.attach(self.label_umu_runtime_last, 0, 8, 1, 1) + grid_umu.attach(self.button_umu_runtime, 0, 9, 1, 1) + grid_umu.attach(self.progress_umu_runtime, 0, 10, 2, 1) grid_miscellaneous.attach(self.checkbox_discrete_gpu, 0, 2, 1, 1) grid_miscellaneous.attach(self.checkbox_show_hidden, 0, 3, 1, 1) @@ -377,7 +386,10 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): self.box.add(box_bottom) self.populate_combobox_with_runners() + self.combobox_runner.connect("changed", self._on_runner_changed) self.load_config() + # Update runtime display to reflect the loaded config selection + self._update_runtime_variant() self.show_all() self.progress_umu.set_visible(False) @@ -494,6 +506,23 @@ class SettingsDialog(EntryTooltipMixin, Gtk.Dialog): from fungus.utils import populate_combobox_with_runners as _pop _pop(self.combobox_runner) + def _on_runner_changed(self, combobox): + """Handle runner selection change: update runtime variant display.""" + self._update_runtime_variant() + + def _update_runtime_variant(self): + """Update the runtime variant label based on the selected Proton runner.""" + runner = self.combobox_runner.get_active_text() + if runner: + variant = proton_to_steamrt_variant(runner) + self.label_umu_runtime_variant.set_text(f"Expected: {variant}") + self.label_umu_runtime_variant.set_sensitive(True) + # Invalidate last-checked since the runtime may differ + self.label_umu_runtime_last.set_text("Last checked: -") + else: + self.label_umu_runtime_variant.set_text("Expected: steamrt3") + self.label_umu_runtime_variant.set_sensitive(False) + def on_entry_changed(self, widget, entry): """Remove the 'required' CSS class once the entry has text.""" if entry.get_text(): diff --git a/fungus/umu_manager.py b/fungus/umu_manager.py index 21d80f3..388bf79 100644 --- a/fungus/umu_manager.py +++ b/fungus/umu_manager.py @@ -6,6 +6,7 @@ locally installed version, and download/install the binary. """ import os +import re import subprocess import tarfile import tempfile @@ -32,6 +33,51 @@ def get_umu_run_path() -> str: return str(umu_run) +def extract_proton_version(proton_dir: str | None) -> str | None: + """Extract the major Proton version number from a directory name. + + Handles common naming conventions: + "Proton-11.0-1" → "11" + "Proton-10.0-1" → "10" + "GE-Proton11-1" → "11" + "GE-Proton10-1" → "10" + "GE-Proton9-11" → "9" + "EM-1.0" → "1" + + Returns ``None`` if the version cannot be parsed. + """ + name = proton_dir + if not name: + return None + + # Strip known prefixes + for prefix in ("GE-Proton", "Proton-", "EM-"): + if name.startswith(prefix): + name = name[len(prefix):] + break + + # Extract leading digits + match = re.match(r"(\d+)", name) + return match.group(1) if match else None + + +def proton_to_steamrt_variant(proton_dir: str | None) -> str: + """Return the expected Steam Runtime variant for a Proton directory name. + + Proton major version >= 11 uses steamrt4; everything else uses steamrt3. + Falls back to ``"steamrt3"`` when the version cannot be parsed. + """ + version = extract_proton_version(proton_dir) + if version is None: + return "steamrt3" + if int(version) >= 11: + return "steamrt4" + return "steamrt3" + """Return the path to the umu-run binary.""" + from fungus.constants import umu_run + return str(umu_run) + + def get_latest_umu_version() -> str | None: """Query the GitHub releases API for the latest UMU-Launcher tag. @@ -251,8 +297,8 @@ def update_steam_runtime( """Trigger the UMU Steam Runtime download/update for a given Proton path. Runs ``umu-run wineprefixcreate /usr/bin/true`` with the appropriate - ``PROTONPATH`` environment variable, which causes umu-run to download - and install the Steam Runtime (steamrt3) if missing. + ``PROTONPATH`` and ``PROTONVERSION`` environment variables, which causes + umu-run to download and install the correct Steam Runtime variant if missing. Args: protonpath: The Proton directory name (e.g. ``"Proton-9.0"``). @@ -272,6 +318,9 @@ def update_steam_runtime( env = os.environ.copy() env["GAMEID"] = "umu-update-handshake" env["PROTONPATH"] = str(proton_path) + proton_version = extract_proton_version(protonpath) + if proton_version: + env["PROTONVERSION"] = proton_version try: proc = subprocess.Popen( |
