Files
DroidDeck/tools/linuxfs/overlay/usr/local/bin/droiddeck-desktop-games
T
The412Banner db8d1c9910 feat: optional x86-64 Steam client (Valve's Linux client under FEX) beside the arm64 one (#152)
An opt-in second Steam client (Steam settings, Steam client: x86-64): Valve's
x86-64 Linux client, unchanged, runs under FEX in its own home with its own
game library and the same sign-in. Linux builds run directly, so titles such
as Team Fortress 2 and Half-Life use their Linux versions; Windows games use
DroidDeck-Proton as on arm64. The arm64 client stays the default.

- droiddeck-steam-x64: FEX and the x86-64 rootfs from DroidDeck-Components
  (sha256-pinned), client install and sync from Valve's CDN, sign-in shared
  with the arm64 client, its web helper on the GPU (ANGLE GL over FEX's GL
  thunk, zink, Turnip), Proton wrappers for the arm64 client's tools,
  DroidDeck direct for Linux builds, SD-card library (x86-64/ beside the
  arm64 one), repair.
- FEX 2610 built by build-fex.yml with thunks and three patches: an openat2
  fallback without openat2 (proot), newer-clang thunkgen, MAP_32BIT
  exhaustion returning ENOMEM. libblsession resolves RESOLVE_IN_ROOT paths
  inside the root.
- Session: x86-64 gating, shortcuts and compatibility tools per client,
  logs from the client that ran.
- App: client setting with the FEX version, an x86-64 chip on the Games
  header, the active client's library, art, storage, downloads, repair,
  Offline Mode, Decky, desktop mode, optional VAC diagnostics; per-client
  state for art, the content log, repair and leftovers.
- Strings in every locale.
- Review fixes: the library cache is saved only by the newest scan; an
  abandoned session's Steam logs come from the client it recorded; distinct
  VAC console names; FEXInterpreter in CPU pinning; clearer VAC hint in
  pl, ru, uk, cs and bg.
2026-10-17 23:57:52 -04:00

138 lines
5.0 KiB
Python
Executable File

#!/usr/bin/python3
import os
import re
import sys
HOME = os.environ.get("HOME", "/root")
X64 = os.environ.get("BL_STEAM_CLIENT_ARCH") == "x86_64"
CLIENT_HOME = (os.environ.get("BL_X64_HOME") or os.path.join(HOME, ".droiddeck-x64")) if X64 else HOME
STEAM_ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(CLIENT_HOME, ".local/share/Steam")
LIBRARIES = ((STEAM_ROOT, "Steam Games"), ("/mnt/droiddeck-sd/x86-64" if X64 else "/mnt/droiddeck-sd", "SD Games"))
NOT_GAMES = {228980, 1070560, 1391110, 1493710, 1628350, 3127680, 4183110, 4185400, 4427310, 4628740}
APPS_DIR = os.path.join(HOME, ".local/share/applications")
PREFIX = "droiddeck-game-"
NAME = re.compile(r'^\s*"name"\s*"([^"]*)"', re.M)
STATE = re.compile(r'^\s*"StateFlags"\s*"(\d+)"', re.M)
INSTALLDIR = re.compile(r'^\s*"installdir"\s*"([^"]*)"', re.M)
def games(library):
steamapps = os.path.join(library, "steamapps")
out = []
if not os.path.isdir(steamapps):
return out
for entry in sorted(os.listdir(steamapps)):
m = re.fullmatch(r"appmanifest_(\d+)\.acf", entry)
if not m:
continue
appid = int(m.group(1))
if appid in NOT_GAMES:
continue
try:
with open(os.path.join(steamapps, entry), encoding="utf-8", errors="replace") as f:
text = f.read()
except OSError:
continue
name = NAME.search(text)
state = STATE.search(text)
if not name or not state or (int(state.group(1)) & 4) == 0:
continue
installdir = INSTALLDIR.search(text)
if installdir and os.path.isfile(os.path.join(steamapps, "common", installdir.group(1), "toolmanifest.vdf")):
continue
out.append((appid, name.group(1)))
return out
def icon_for(appid):
cache = os.path.join(STEAM_ROOT, "appcache/librarycache", str(appid))
for candidate in ("logo.png", "library_600x900.jpg", "header.jpg"):
path = os.path.join(cache, candidate)
if os.path.isfile(path):
return path
return "steam"
def client_entries():
"""App ids the client already wrote a menu entry for."""
found = set()
if not os.path.isdir(APPS_DIR):
return found
for entry in os.listdir(APPS_DIR):
if entry.startswith(PREFIX) or not entry.endswith(".desktop"):
continue
try:
with open(os.path.join(APPS_DIR, entry), encoding="utf-8", errors="replace") as f:
m = re.search(r"steam://rungameid/(\d+)", f.read())
except OSError:
continue
if m:
found.add(int(m.group(1)))
return found
def registered():
try:
with open(os.path.join(STEAM_ROOT, "steamapps", "libraryfolders.vdf"), encoding="utf-8", errors="replace") as f:
return [path.replace("\\\\", "\\") for path in re.findall(r'"path"\s+"((?:[^"\\]|\\.)*)"', f.read())]
except OSError:
return []
def write_entries():
os.makedirs(APPS_DIR, exist_ok=True)
wanted = {}
theirs = client_entries()
for library in dict.fromkeys([library for library, _ in LIBRARIES] + registered()):
for appid, name in games(library):
if appid not in theirs:
wanted.setdefault(appid, name)
for entry in os.listdir(APPS_DIR):
if entry.startswith(PREFIX) and entry.endswith(".desktop"):
appid = entry[len(PREFIX):-len(".desktop")]
if not appid.isdigit() or int(appid) not in wanted:
os.unlink(os.path.join(APPS_DIR, entry))
for appid, name in wanted.items():
safe = name.replace("\n", " ").strip() or str(appid)
body = (
"[Desktop Entry]\nType=Application\nName=%s\nComment=Steam game %d - opens in Steam under gamescope\n"
"Exec=/usr/local/bin/droiddeck-steam-launch desktop %d\nIcon=%s\nTerminal=false\n"
"Categories=Game;\nX-DroidDeck-AppId=%d\n" % (safe, appid, appid, icon_for(appid), appid)
)
path = os.path.join(APPS_DIR, "%s%d.desktop" % (PREFIX, appid))
try:
with open(path, encoding="utf-8") as f:
if f.read() == body:
continue
except OSError:
pass
with open(path, "w", encoding="utf-8") as f:
f.write(body)
return wanted
def link_libraries():
for library, label in LIBRARIES:
common = os.path.join(library, "steamapps", "common")
link = os.path.join(HOME, label)
if os.path.isdir(common):
if os.path.islink(link) and os.readlink(link) == common:
continue
if os.path.islink(link) or os.path.isfile(link):
os.unlink(link)
if not os.path.exists(link):
os.symlink(common, link)
elif os.path.islink(link):
os.unlink(link)
def main():
wanted = write_entries()
link_libraries()
print("droiddeck-desktop-games: %d entr%s of ours, %d the client's" % (
len(wanted), "y" if len(wanted) == 1 else "ies", len(client_entries())))
if __name__ == "__main__":
main()