python/steamutil: Add steam flatpak support

master
Taeyeon Mori 2 months ago
parent 7b07696298
commit b5cf6558cd
  1. 13
      lib/python/steamutil.py

@ -328,11 +328,10 @@ class Steam:
@staticmethod @staticmethod
def find_install_path() -> Optional[Path]: def find_install_path() -> Optional[Path]:
# TODO: Windows
# Linux # Linux
if sys.platform.startswith("linux"): if sys.platform.startswith("linux"):
# Try ~/.steam first # Try ~/.steam first
dotsteam = Path(os.path.expanduser("~/.steam")) dotsteam = Path("~/.steam").expanduser()
if dotsteam.exists(): if dotsteam.exists():
steamroot = (dotsteam / "root").resolve() steamroot = (dotsteam / "root").resolve()
if steamroot.exists(): if steamroot.exists():
@ -342,8 +341,12 @@ class Steam:
for path in data_dir, Path("~").expanduser(): for path in data_dir, Path("~").expanduser():
for name in "Steam", "SteamBeta": for name in "Steam", "SteamBeta":
steamroot = path / name steamroot = path / name
if steamroot.exists(): if (steamroot / "steamapps" / "libraryfolders.vdf").exists():
return steamroot 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"): elif sys.platform.startswith("win"):
try: try:
import winreg import winreg
@ -363,6 +366,10 @@ class Steam:
return path return path
return None return None
@property
def is_flatpak(self) -> bool:
return self.root.is_relative_to(Path("~/.var/app/com.valvesoftware.Steam").expanduser())
# Various paths # Various paths
@property @property
def libraryfolders_vdf(self) -> Path: def libraryfolders_vdf(self) -> Path:

Loading…
Cancel
Save