From de1dfca57eb6e779487cf7625076ab0f48459aa1 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Tue, 3 Jun 2025 13:33:48 +0100 Subject: [PATCH] fix: fixing playtime dir on linux --- python_rpc/main.py | 23 +++++++++++++++++++++-- src/main/services/steam.ts | 30 +++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/python_rpc/main.py b/python_rpc/main.py index 43972afa..70c83c8a 100644 --- a/python_rpc/main.py +++ b/python_rpc/main.py @@ -4,6 +4,7 @@ from torrent_downloader import TorrentDownloader from http_downloader import HttpDownloader from profile_image_processor import ProfileImageProcessor import libtorrent as lt +import os app = Flask(__name__) @@ -102,8 +103,26 @@ def process_list(): if auth_error: return auth_error - process_list = [proc.info for proc in psutil.process_iter(['exe', 'cwd', 'pid', 'name', 'environ'])] - return jsonify(process_list), 200 + processes = [] + + for proc in psutil.process_iter(['exe', 'cwd', 'pid', 'cmdline']): + try: + info = proc.info + cmdline = info.get('cmdline') or [] + wine_launched_exe = None + + for arg in cmdline: + if isinstance(arg, str) and arg.lower().endswith(".exe"): + wine_launched_exe = os.path.basename(arg) + break + + exe_path = info.get('exe') or '' + info['name'] = wine_launched_exe or os.path.basename(exe_path) + processes.append(info) + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + + return jsonify(processes), 200 @app.route("/profile-image", methods=["POST"]) def profile_image(): diff --git a/src/main/services/steam.ts b/src/main/services/steam.ts index 70653fd0..e981f4b0 100644 --- a/src/main/services/steam.ts +++ b/src/main/services/steam.ts @@ -17,18 +17,30 @@ export interface SteamAppDetailsResponse { }; } -export const getSteamLocation = async () => { +export const getSteamLocation = async (): Promise => { + const home = SystemPath.getPath("home"); + if (process.platform === "linux") { - return path.join(SystemPath.getPath("home"), ".local", "share", "Steam"); + const candidates = [ + path.join(home, ".local", "share", "Steam"), + path.join(home, ".steam", "steam"), + path.join(home, ".steam", "root"), + ]; + + for (const candidate of candidates) { + try { + fs.accessSync(candidate, fs.constants.F_OK); + return candidate; + } catch { + continue; + } + } + + throw new Error("Steam installation not found on Linux"); } if (process.platform === "darwin") { - return path.join( - SystemPath.getPath("home"), - "Library", - "Application Support", - "Steam" - ); + return path.join(home, "Library", "Application Support", "Steam"); } const regKey = new WinReg({ @@ -39,7 +51,7 @@ export const getSteamLocation = async () => { return new Promise((resolve, reject) => { regKey.get("SteamPath", (err, value) => { if (err) { - reject(err); + return reject(err); } resolve(value.value);