From 2bfd020d030ed30645525cd12e9fc9933cb27f41 Mon Sep 17 00:00:00 2001 From: cyberrumor Date: Sat, 14 Dec 2024 16:15:00 -0800 Subject: [PATCH] Detect steam install location from symlink (#69) Try to get the steam install location from the symlink ~/.steam/steam, and if it can't be found, fallback to the old location of ~/.local/share/Steam. --- ammo/controller/game.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ammo/controller/game.py b/ammo/controller/game.py index 887a7ee..460757a 100755 --- a/ammo/controller/game.py +++ b/ammo/controller/game.py @@ -166,7 +166,20 @@ def __init__(self, args): # Find games from instances of Steam self.libraries: list[Path] = [] - self.steam = Path.home() / ".local/share/Steam/steamapps" + # ~/.steam/steam is a symlink usually pointing to ~/.local/share/Steam, + # but the location it points to might be different for unknown reasons. + # Trust the symlink location to point to the correct steam install location. + if all( + ( + (steam := Path.home() / ".steam" / "steam").exists(), + steam.is_symlink(), + steam.readlink().exists(), + ) + ): + self.steam = (Path.home() / ".steam" / "steam").resolve() / "steamapps" + else: + # The symlink at ~/.steam/steam was broken. Fallback to a sane default. + self.steam = Path.home() / ".local/share/Steam/steamapps" self.flatpak = ( Path.home() / ".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps"