- steam-egpu-patch-all.py: patcht localconfig.vdf (124 spiele auf einmal) - steam-egpu: launcher der vor jedem start neue spiele sync't - steam-egpu.desktop: ersetzt den normalen steam-launcher
119 lines
3.8 KiB
Python
119 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Patcht Steam localconfig.vdf — setzt superx-game-wrapper für ALLE Spiele.
|
|
|
|
Usage:
|
|
python tools/steam-egpu-patch-all.py # alle Spiele patchen
|
|
python tools/steam-egpu-patch-all.py --undo # Wrapper entfernen
|
|
python tools/steam-egpu-patch-all.py --dry-run # nur anzeigen
|
|
|
|
Danach Steam neustarten.
|
|
"""
|
|
import json, subprocess, sys, os, shutil, argparse
|
|
from pathlib import Path
|
|
|
|
STEAM_DIR = Path.home() / ".local/share/Steam"
|
|
USERDATA = STEAM_DIR / "userdata" / "19491507" / "config" / "localconfig.vdf"
|
|
|
|
WRAPPER = "/home/nepharius/SuperX-goes-Arch/tools/superx-game-wrapper.sh %command%"
|
|
LAUNCH_KEY = "LaunchOptions"
|
|
|
|
|
|
def parse_args():
|
|
parser = argparse.ArgumentParser(description="Steam Launch Options für eGPU-Wrapper patchen")
|
|
parser.add_argument("--undo", action="store_true", help="Wrapper aus allen Spielen entfernen")
|
|
parser.add_argument("--dry-run", action="store_true", help="Nur anzeigen, nicht schreiben")
|
|
parser.add_argument("--yes", "-y", action="store_true", help="Keine Bestätigungsfrage")
|
|
return parser.parse_args()
|
|
|
|
|
|
def main():
|
|
args = parse_args()
|
|
|
|
if not USERDATA.exists():
|
|
print(f"ERROR: {USERDATA} nicht gefunden. Steam jemals gestartet?")
|
|
sys.exit(1)
|
|
|
|
# VDF parsen
|
|
import vdf
|
|
with open(USERDATA) as f:
|
|
raw = f.read()
|
|
config = vdf.loads(raw)
|
|
|
|
apps = config.get("UserLocalConfigStore", {}).get("Software", {}).get(
|
|
"Valve", {}
|
|
).get("Steam", {}).get("apps", {})
|
|
|
|
if not apps:
|
|
print("Keine Apps in localconfig.vdf gefunden. Steam muss mindestens einmal gestartet sein.")
|
|
sys.exit(1)
|
|
|
|
total = len(apps)
|
|
count_wrapper = 0
|
|
count_other = 0
|
|
count_empty = 0
|
|
count_patched = 0
|
|
count_removed = 0
|
|
|
|
for appid, appcfg in apps.items():
|
|
current = appcfg.get(LAUNCH_KEY, "")
|
|
if current == WRAPPER:
|
|
count_wrapper += 1
|
|
elif current:
|
|
count_other += 1
|
|
else:
|
|
count_empty += 1
|
|
|
|
print(f"Spiele insgesamt: {total}")
|
|
print(f" {count_wrapper} haben bereits den Wrapper")
|
|
print(f" {count_other} haben andere Launch Options")
|
|
print(f" {count_empty} haben keine Launch Options")
|
|
print()
|
|
|
|
if args.dry_run:
|
|
if args.undo:
|
|
print(f"[DRY-RUN] Würde Wrapper aus {count_wrapper} Spielen entfernen")
|
|
else:
|
|
target = total - count_wrapper
|
|
print(f"[DRY-RUN] Würde Wrapper in {target} Spielen setzen")
|
|
if count_other > 0:
|
|
print(f"[DRY-RUN] ACHTUNG: {count_other} Spiele mit bestehenden Launch Options werden ÜBERSCHRIEBEN!")
|
|
return
|
|
|
|
# Backup
|
|
backup = USERDATA.with_suffix(".vdf.bak")
|
|
shutil.copy2(USERDATA, backup)
|
|
print(f"Backup: {backup}")
|
|
|
|
if args.undo:
|
|
for appid, appcfg in apps.items():
|
|
if appcfg.get(LAUNCH_KEY) == WRAPPER:
|
|
del appcfg[LAUNCH_KEY]
|
|
count_removed += 1
|
|
print(f"Wrapper entfernt aus {count_removed} Spielen")
|
|
else:
|
|
for appid, appcfg in apps.items():
|
|
if appcfg.get(LAUNCH_KEY) == WRAPPER:
|
|
continue
|
|
appcfg[LAUNCH_KEY] = WRAPPER
|
|
count_patched += 1
|
|
print(f"Wrapper gesetzt in {count_patched} Spielen")
|
|
if count_other > 0:
|
|
print(f"WARNUNG: {count_other} Spiele hatten andere Launch Options — wurden überschrieben!")
|
|
|
|
# Zurückschreiben
|
|
new_vdf = vdf.dumps(config, pretty=True)
|
|
if not args.yes and sys.stdout.isatty():
|
|
confirm = input("Schreiben? [y/N] ")
|
|
if confirm.lower() != "y":
|
|
print("Abgebrochen.")
|
|
sys.exit(0)
|
|
|
|
with open(USERDATA, "w") as f:
|
|
f.write(new_vdf)
|
|
|
|
print(f"\nFertig. Steam neustarten!")
|
|
print(f"Falls was schiefgeht: cp {backup} {USERDATA}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|