fix(plugin): use full path for mangohud, return empty string instead of unknown
This commit is contained in:
+18
-27
@@ -156,34 +156,25 @@ class Plugin:
|
|||||||
|
|
||||||
async def check_mangohud(self) -> dict:
|
async def check_mangohud(self) -> dict:
|
||||||
"""RPC: Check if MangoHud is installed. Returns {installed: bool, path: str, version: str}."""
|
"""RPC: Check if MangoHud is installed. Returns {installed: bool, path: str, version: str}."""
|
||||||
import subprocess
|
import subprocess as sp
|
||||||
|
import os
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
# Use the full path to avoid PATH issues
|
||||||
["which", "mangohud"],
|
mangohud_path = "/usr/bin/mangohud"
|
||||||
capture_output=True, text=True, timeout=5
|
if not os.path.exists(mangohud_path):
|
||||||
)
|
# Fall back to which
|
||||||
if result.returncode == 0:
|
r = sp.run(["which", "mangohud"], capture_output=True, text=True, timeout=5)
|
||||||
mangohud_path = result.stdout.strip()
|
if r.returncode != 0:
|
||||||
# Get version
|
return {"installed": False, "path": "", "version": ""}
|
||||||
version_result = subprocess.run(
|
mangohud_path = r.stdout.strip()
|
||||||
["mangohud", "--version"],
|
|
||||||
capture_output=True, text=True, timeout=5
|
# Get version using the full path
|
||||||
)
|
v = sp.run([mangohud_path, "--version"], capture_output=True, text=True, timeout=5)
|
||||||
version = version_result.stdout.strip() if version_result.returncode == 0 else "unknown"
|
version = v.stdout.strip() if v.returncode == 0 else ""
|
||||||
# Clean up version string (remove git hash suffix)
|
if version and "-" in version:
|
||||||
if version and "-" in version:
|
version = version.split("-")[0]
|
||||||
version = version.split("-")[0]
|
|
||||||
# Fallback: try with full path if first attempt failed
|
return {"installed": True, "path": mangohud_path, "version": version or ""}
|
||||||
if version == "unknown" and mangohud_path:
|
|
||||||
try:
|
|
||||||
v2 = subprocess.run([mangohud_path, "--version"], capture_output=True, text=True, timeout=5)
|
|
||||||
if v2.returncode == 0:
|
|
||||||
version = v2.stdout.strip().split("-")[0]
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return {"installed": True, "path": mangohud_path, "version": version}
|
|
||||||
else:
|
|
||||||
return {"installed": False, "path": "", "version": ""}
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"installed": False, "path": "", "version": "", "error": str(e)}
|
return {"installed": False, "path": "", "version": "", "error": str(e)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user