From b5cf6558cd8289cec4850c541c2dc2b20ce4e30e Mon Sep 17 00:00:00 2001 From: Taeyeon Mori Date: Fri, 18 Oct 2024 14:44:54 +0200 Subject: [PATCH] python/steamutil: Add steam flatpak support --- lib/python/steamutil.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/python/steamutil.py b/lib/python/steamutil.py index c5a1b71..ac6eb37 100644 --- a/lib/python/steamutil.py +++ b/lib/python/steamutil.py @@ -328,11 +328,10 @@ class Steam: @staticmethod def find_install_path() -> Optional[Path]: - # TODO: Windows # Linux if sys.platform.startswith("linux"): # Try ~/.steam first - dotsteam = Path(os.path.expanduser("~/.steam")) + dotsteam = Path("~/.steam").expanduser() if dotsteam.exists(): steamroot = (dotsteam / "root").resolve() if steamroot.exists(): @@ -342,8 +341,12 @@ class Steam: for path in data_dir, Path("~").expanduser(): for name in "Steam", "SteamBeta": steamroot = path / name - if steamroot.exists(): + if (steamroot / "steamapps" / "libraryfolders.vdf").exists(): return steamroot + # Try Flatpak + appdir = Path("~/.var/app/com.valvesoftware.Steam").expanduser() + if appdir.exists(): + return (appdir / ".steam" / "root").resolve() elif sys.platform.startswith("win"): try: import winreg @@ -363,6 +366,10 @@ class Steam: return path return None + @property + def is_flatpak(self) -> bool: + return self.root.is_relative_to(Path("~/.var/app/com.valvesoftware.Steam").expanduser()) + # Various paths @property def libraryfolders_vdf(self) -> Path: