Skip to content

Commit

Permalink
Detect steam install location from symlink (#69)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cyberrumor committed Dec 15, 2024
1 parent 4cf2b53 commit 2bfd020
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ammo/controller/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2bfd020

Please sign in to comment.