diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c4dcbe..f80db64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added - `--cwd-app` flag to set working directory to the game's installation directory + - Add support Snap Steam installations ### Changed - `protontricks -c` and `protontricks-launch` now use the current working directory instead of the game's installation directory. `--cwd-app` can be used to restore old behavior. Scripts can also `$STEAM_APP_PATH` environment variable to determine the game's installation directory; this has been supported (albeit undocumented) since 1.8.0. diff --git a/src/protontricks/gui.py b/src/protontricks/gui.py index 1c02496..f47cd52 100644 --- a/src/protontricks/gui.py +++ b/src/protontricks/gui.py @@ -15,6 +15,7 @@ from .config import get_config from .flatpak import get_inaccessible_paths from .util import get_cache_dir +from .steam import SNAP_STEAM_DIRS APP_ICON_SIZE = (32, 32) @@ -251,7 +252,17 @@ def _get_zenity_args(): "/com.valvesoftware.Steam/.local/share/Steam" ) ) - install_type = "Flatpak" if is_flatpak else "Native" + is_snap = any( + str(steam_path).endswith(snap_dir) + for snap_dir in SNAP_STEAM_DIRS + ) + + if is_flatpak: + install_type = "Flatpak" + elif is_snap: + install_type = "Snap" + else: + install_type = "Native" cmd_input.append(f"{i+1}: {install_type} - {steam_path}") diff --git a/src/protontricks/steam.py b/src/protontricks/steam.py index bcae17e..11ca2e7 100644 --- a/src/protontricks/steam.py +++ b/src/protontricks/steam.py @@ -27,6 +27,11 @@ ".local/share/Steam", ] +SNAP_STEAM_DIRS = [ + "snap/steam", + ".snap/data/steam" +] + OS_RELEASE_PATHS = [ "/run/host/os-release", # The host file if we're inside a Flatpak sandbox "/etc/os-release" @@ -388,14 +393,19 @@ def has_runtime_dir(path): candidates[(str(steam_path), str(steam_root_))] = True - # Check for Flatpak Steam separately and ensure we don't mix steam_root - # and steam_path from Flatpak and non-Flatpak installations of Steam. + # Check for Flatpak and Snap Steam separately and ensure we don't mix steam_root + # and steam_path from Flatpak/Snap and native installations of Steam. steam_path = \ Path.home() / ".var/app/com.valvesoftware.Steam/data/Steam" steam_path = steam_path.resolve() if has_steamapps_dir(steam_path): candidates[(str(steam_path), str(steam_path))] = True + for steam_dir in SNAP_STEAM_DIRS: + steam_path = (Path.home() / steam_dir).resolve() + if has_steamapps_dir(steam_path): + candidates[(str(steam_path), str(steam_path))] = True + for steam_path, _ in candidates.keys(): logger.info("Found Steam directory at %s", steam_path)