fix(plugin): use autostart_log instead of mangohudctl, improve log search

This commit is contained in:
2026-06-28 20:29:38 +08:00
parent f61227e7fc
commit aa52e0feb6
2 changed files with 17 additions and 24 deletions
+16 -17
View File
@@ -186,12 +186,11 @@ class Plugin:
os.makedirs(config_dir, exist_ok=True) os.makedirs(config_dir, exist_ok=True)
# MangoHud config that enables logging with the metrics we need. # MangoHud config that enables logging with the metrics we need.
# output_folder is required for logging to work. # autostart_log starts logging immediately when MangoHud initializes.
# We log to /tmp so the plugin can read it after the session.
config_content = """\ config_content = """\
# DeckyVault MangoHud logging config # DeckyVault MangoHud logging config
output_folder=/tmp output_folder=/tmp
output_file=deckyvault-mangohud.log autostart_log=0
fps fps
frame_timing frame_timing
cpu_power cpu_power
@@ -254,21 +253,20 @@ benchmark_percentiles=97,AVG,1,0.1
"""Find the most recent MangoHud log file in /tmp/. """Find the most recent MangoHud log file in /tmp/.
MangoHud creates log files with the game name and timestamp.""" MangoHud creates log files with the game name and timestamp."""
import glob import glob
# Look for any CSV or log files in /tmp that might be MangoHud logs
candidates = [] candidates = []
for pattern in ["/tmp/*.csv", "/tmp/*.log", "/tmp/MangoHud*"]: # MangoHud log files are typically .csv or have MangoHud in the name
for pattern in ["/tmp/*MangoHud*", "/tmp/*.csv", "/tmp/*.log"]:
for f in glob.glob(pattern): for f in glob.glob(pattern):
# Skip our own known file # Skip directories
if "deckyvault" in f: if os.path.isdir(f):
candidates.append(f)
continue continue
# Check if the file starts with a MangoHud header # Check if it looks like a MangoHud log (has fps/frametime header)
try: try:
with open(f, 'r') as fh: with open(f, 'r') as fh:
first_line = fh.readline() first_lines = "".join(fh.readline() for _ in range(5))
if 'MangoHud' in first_line or 'fps' in first_line.lower(): if 'fps' in first_lines.lower() or 'MangoHud' in first_lines:
candidates.append(f) candidates.append(f)
except (IOError, UnicodeDecodeError): except (IOError, UnicodeDecodeError, PermissionError):
pass pass
if not candidates: if not candidates:
return None return None
@@ -299,12 +297,13 @@ benchmark_percentiles=97,AVG,1,0.1
"""RPC: Delete all MangoHud log files in /tmp/ so the next recording starts fresh.""" """RPC: Delete all MangoHud log files in /tmp/ so the next recording starts fresh."""
import glob import glob
try: try:
for pattern in ["/tmp/*.csv", "/tmp/*.log", "/tmp/MangoHud*"]: for pattern in ["/tmp/*MangoHud*", "/tmp/*.csv", "/tmp/*.log"]:
for f in glob.glob(pattern): for f in glob.glob(pattern):
try: if os.path.isfile(f):
os.remove(f) try:
except (IOError, PermissionError): os.remove(f)
pass except (IOError, PermissionError):
pass
return {"success": True} return {"success": True}
except Exception as e: except Exception as e:
return {"success": False, "error": str(e)} return {"success": False, "error": str(e)}
+1 -7
View File
@@ -14,8 +14,6 @@ import {
readAndParseMangohudLog, readAndParseMangohudLog,
clearMangohudLog, clearMangohudLog,
writeMangohudConfig, writeMangohudConfig,
startMangohudLogging,
stopMangohudLogging,
getHardwareInfo, getHardwareInfo,
getOsVersion, getOsVersion,
getProtonVersion, getProtonVersion,
@@ -72,20 +70,16 @@ function Content() {
// ── Handle start recording ──────────────────────────────────── // ── Handle start recording ────────────────────────────────────
async function handleStart() { async function handleStart() {
// Write MangoHud config with logging settings // Write MangoHud config with autostart_log so logging begins on game launch
await writeMangohudConfig() await writeMangohudConfig()
// Clear any previous log file // Clear any previous log file
await clearMangohudLog() await clearMangohudLog()
// Start MangoHud logging via mangohudctl
await startMangohudLogging()
startRecording() startRecording()
} }
// ── Handle stop recording: parse log + read system info ──────── // ── Handle stop recording: parse log + read system info ────────
async function handleStop() { async function handleStop() {
try { try {
// Stop MangoHud logging via mangohudctl
await stopMangohudLogging()
stopRecording() stopRecording()
// Parse the MangoHud log // Parse the MangoHud log