fix(plugin): browser-like UA for Cloudflare, detect current game, fix proton version, single-line notes
This commit is contained in:
@@ -411,20 +411,63 @@ exec mangohud "$@"
|
|||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
||||||
async def get_proton_version(self, app_id: int) -> str:
|
async def get_proton_version(self, app_id: int) -> str:
|
||||||
"""RPC: Attempt to read the Proton version for a Steam app.
|
"""RPC: Read the Proton version for a Steam app from config_info."""
|
||||||
Reads from the Steam compatdata directory."""
|
|
||||||
try:
|
try:
|
||||||
home = os.path.expanduser("~")
|
home = os.path.expanduser("~")
|
||||||
# Steam compat data lives in ~/.steam/steam/steamapps/compatdata/<appid>/
|
config_path = os.path.join(home, ".steam", "steam", "steamapps", "compatdata", str(app_id), "config_info")
|
||||||
compat_path = os.path.join(home, ".steam", "steam", "steamapps", "compatdata", str(app_id))
|
if os.path.exists(config_path):
|
||||||
version_file = os.path.join(compat_path, "version")
|
with open(config_path, 'r') as f:
|
||||||
if os.path.exists(version_file):
|
lines = f.readlines()
|
||||||
with open(version_file, 'r') as f:
|
if len(lines) >= 2:
|
||||||
return f.read().strip()
|
proton_path = lines[1].strip()
|
||||||
|
import re
|
||||||
|
m = re.search(r'Proton[\s]+([\d.]+)', proton_path)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
return proton_path.split("/")[-1] if proton_path else ""
|
||||||
return ""
|
return ""
|
||||||
except (IOError, FileNotFoundError):
|
except (IOError, FileNotFoundError):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
async def detect_current_game(self) -> dict:
|
||||||
|
"""RPC: Detect the currently running game by checking active window and processes.
|
||||||
|
Returns {appId: int?, name: str}."""
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
|
# Method 1: Try xdotool to get active window title
|
||||||
|
try:
|
||||||
|
r = subprocess.run(
|
||||||
|
["xdotool", "getactivewindow", "getwindowname"],
|
||||||
|
capture_output=True, text=True, timeout=3
|
||||||
|
)
|
||||||
|
if r.returncode == 0:
|
||||||
|
title = r.stdout.strip()
|
||||||
|
if title and title != "Steam" and "Steam" not in title:
|
||||||
|
return {"appId": None, "name": title}
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Method 2: Check for Steam game processes
|
||||||
|
try:
|
||||||
|
r = subprocess.run(
|
||||||
|
["ps", "-eo", "comm", "--no-headers"],
|
||||||
|
capture_output=True, text=True, timeout=3
|
||||||
|
)
|
||||||
|
if r.returncode == 0:
|
||||||
|
# Common game-related processes
|
||||||
|
game_procs = [p for p in r.stdout.split('\n') if p and p not in (
|
||||||
|
'steam', 'steamwebhelper', 'steamservice', 'steamclient',
|
||||||
|
'bash', 'python3', 'mangohud', 'gamescope', 'Xorg',
|
||||||
|
'kwin_wayland', 'plasmashell', 'konsole', 'dolphin'
|
||||||
|
)]
|
||||||
|
if game_procs:
|
||||||
|
return {"appId": None, "name": game_procs[0]}
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return {"appId": None, "name": ""}
|
||||||
|
|
||||||
async def get_launch_options(self, app_id: int) -> str:
|
async def get_launch_options(self, app_id: int) -> str:
|
||||||
"""RPC: Read launch options for a Steam app from localconfig.vdf.
|
"""RPC: Read launch options for a Steam app from localconfig.vdf.
|
||||||
This is best-effort — the VDF format is not officially documented."""
|
This is best-effort — the VDF format is not officially documented."""
|
||||||
@@ -493,6 +536,8 @@ exec mangohud "$@"
|
|||||||
headers={
|
headers={
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"x-api-key": api_key,
|
"x-api-key": api_key,
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/136.0",
|
||||||
|
"Accept": "application/json",
|
||||||
},
|
},
|
||||||
method="POST"
|
method="POST"
|
||||||
)
|
)
|
||||||
@@ -532,7 +577,7 @@ exec mangohud "$@"
|
|||||||
url,
|
url,
|
||||||
headers={
|
headers={
|
||||||
"x-api-key": api_key,
|
"x-api-key": api_key,
|
||||||
"User-Agent": "DeckyVaultPlugin/0.1",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:136.0) Gecko/20100101 Firefox/136.0",
|
||||||
},
|
},
|
||||||
method="GET"
|
method="GET"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -186,16 +186,12 @@ export default function SessionForm({
|
|||||||
</PanelSectionRow>
|
</PanelSectionRow>
|
||||||
|
|
||||||
<PanelSectionRow>
|
<PanelSectionRow>
|
||||||
<Field label="Notes" bottomSeparator="none">
|
<TextField
|
||||||
<textarea
|
label="Notes"
|
||||||
value={session.userNotes}
|
value={session.userNotes}
|
||||||
onChange={(e) => onUpdateSession({ userNotes: e.target.value })}
|
onChange={(e) => onUpdateSession({ userNotes: e.target.value })}
|
||||||
placeholder="Any observations about performance..."
|
placeholder="Any observations about performance..."
|
||||||
rows={3}
|
/>
|
||||||
maxLength={5000}
|
|
||||||
style={{ width: "100%", padding: "4px 8px", resize: "vertical" }}
|
|
||||||
/>
|
|
||||||
</Field>
|
|
||||||
</PanelSectionRow>
|
</PanelSectionRow>
|
||||||
</PanelSection>
|
</PanelSection>
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,11 @@ export const testApiKey = callable<[apiKey: string, baseUrl?: string], {
|
|||||||
error?: string
|
error?: string
|
||||||
}>("test_api_key")
|
}>("test_api_key")
|
||||||
|
|
||||||
|
export const detectCurrentGame = callable<[], {
|
||||||
|
appId: number | null
|
||||||
|
name: string
|
||||||
|
}>("detect_current_game")
|
||||||
|
|
||||||
export const debugListTmp = callable<[], {
|
export const debugListTmp = callable<[], {
|
||||||
files: Array<{ name: string; size: number; mtime: number }>
|
files: Array<{ name: string; size: number; mtime: number }>
|
||||||
}>("debug_list_tmp")
|
}>("debug_list_tmp")
|
||||||
|
|||||||
Reference in New Issue
Block a user