fix(plugin): read mangohud version from script file instead of running it
This commit is contained in:
+15
-14
@@ -157,29 +157,30 @@ class Plugin:
|
|||||||
async def check_mangohud(self) -> dict:
|
async def check_mangohud(self) -> dict:
|
||||||
"""RPC: Check if MangoHud is installed."""
|
"""RPC: Check if MangoHud is installed."""
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
try:
|
try:
|
||||||
path = "/usr/bin/mangohud"
|
path = "/usr/bin/mangohud"
|
||||||
exists = os.path.exists(path)
|
exists = os.path.exists(path)
|
||||||
if not exists:
|
if not exists:
|
||||||
return {"installed": False, "path": "", "version": "", "debug": "file not found"}
|
return {"installed": False, "path": "", "version": ""}
|
||||||
|
|
||||||
# Get version using os.popen
|
# Read version from the shell script itself
|
||||||
version = ""
|
version = ""
|
||||||
debug = ""
|
|
||||||
try:
|
try:
|
||||||
with os.popen(f"{path} --version 2>&1") as pipe:
|
with open(path, 'r') as f:
|
||||||
v = pipe.read().strip()
|
content = f.read()
|
||||||
debug = f"popen got: {repr(v)}"
|
# Look for the version line: echo v0.8.3-rc1-24-g33c2c7dd+
|
||||||
if v:
|
m = re.search(r'echo\s+(v?[\d.]+[^\s]*)', content)
|
||||||
if "-" in v:
|
if m:
|
||||||
v = v.split("-")[0]
|
version = m.group(1)
|
||||||
version = v
|
if "-" in version:
|
||||||
except Exception as e:
|
version = version.split("-")[0]
|
||||||
debug = f"popen error: {str(e)}"
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
return {"installed": True, "path": path, "version": version, "debug": debug}
|
return {"installed": True, "path": path, "version": version}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"installed": False, "path": "", "version": "", "error": str(e), "debug": "outer error"}
|
return {"installed": False, "path": "", "version": "", "error": str(e)}
|
||||||
|
|
||||||
async def write_mangohud_config(self) -> dict:
|
async def write_mangohud_config(self) -> dict:
|
||||||
"""RPC: Write the MangoHud logging config to ~/.config/MangoHud/MangoHud.conf.
|
"""RPC: Write the MangoHud logging config to ~/.config/MangoHud/MangoHud.conf.
|
||||||
|
|||||||
Reference in New Issue
Block a user