From 4648a1ad659bf240318198d771a06043a0256c96 Mon Sep 17 00:00:00 2001 From: Tickbase <47538996+Novattz@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:36:04 +0200 Subject: [PATCH] Added function to search for steam binary. --- dlc_fetcher.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dlc_fetcher.py b/dlc_fetcher.py index 1862bf3..d2fa72c 100644 --- a/dlc_fetcher.py +++ b/dlc_fetcher.py @@ -4,6 +4,7 @@ import requests import zipfile import time import stat +import subprocess LOG_FILE = 'script.log' @@ -58,7 +59,18 @@ def parse_vdf(file_path): log_message(f"Failed to read {file_path}: {str(e)}") return library_paths +def find_steam_binary(): + try: + result = subprocess.run(['which', 'steam'], stdout=subprocess.PIPE) + steam_path = result.stdout.decode('utf-8').strip() + if steam_path: + return os.path.dirname(steam_path) + except Exception as e: + log_message(f"Failed to locate steam binary: {str(e)}") + return None + def find_steam_library_folders(): + steam_binary_path = find_steam_binary() base_paths = [ os.path.expanduser('~/.steam/steam'), os.path.expanduser('~/.local/share/Steam'), @@ -67,6 +79,9 @@ def find_steam_library_folders(): '/mnt', '/media', '/run/media/mmcblk0p1/steamapps' ] + if steam_binary_path: + base_paths.append(steam_binary_path) + library_folders = [] try: for base_path in base_paths: