testsAndMisc/linux_configuration/utils/steam_compatibility.sh
Krzysztof kuhy Rudnicki 4f2b0ccdf7 Dissolve linux_configuration/scripts/ and single_use/
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.

Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.

The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:

  - 52 relative `source` lines for lib/common.sh and lib/android.sh. The
    correct prefix differs per file: 40 were ../../ and 12 were ../../../,
    so a blanket replace would have fixed one set and broken the other.
  - REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
    each walking up four levels from a directory now two levels shallower.
    This caused a real regression -- the fixes suite went red with
    "log_warn: command not found" -- caught by running it and comparing
    against the pre-move baseline worktree.
  - conftest.py's sys.path entries, which took the pytest gate down with
    14 collection errors, and the `# shellcheck source=` directives, which
    took shellcheck down with SC1091.

16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.

Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
2026-08-23 18:53:30 +02:00

141 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Steam game compatibility checker for Linux
#
# Features:
# - Gets your games either via Steam Web API (owned library) or by scanning installed appmanifests.
# - Fetches system requirements from Steam Store API (no key required).
# - Compares against your system (CPU, RAM, GPU vendor, OS/arch) with simple heuristics.
# - Ranks games from most to least likely to run.
#
# Optional env vars (for full library):
# STEAM_API_KEY - Your Steam Web API key
# STEAM_ID64 - Your 64-bit Steam ID
#
# Dependencies: curl, jq, awk, sed, grep, sort, lspci, free, uname
# Recommended: timeout (coreutils) to guard slow network calls
set -euo pipefail
# shellcheck source=lib/steam_report.sh
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/steam_report.sh"
# shellcheck source=lib/steam_credentials.sh
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/steam_credentials.sh"
# shellcheck source=lib/steam_api.sh
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/steam_api.sh"
# shellcheck source=lib/steam_requirements.sh
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/steam_requirements.sh"
SCRIPT_NAME=${0##*/}
ABORT=0
on_abort() {
ABORT=1
log "Aborted by user"
exit 130
}
trap on_abort INT TERM
# --------------------------- CLI args ---------------------------
FORCE_REFRESH=0
CLEAR_CACHE=0
VERBOSE=0
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--refresh)
FORCE_REFRESH=1
shift
;;
--clear-cache)
CLEAR_CACHE=1
FORCE_REFRESH=1
shift
;;
-v | --verbose)
VERBOSE=1
shift
;;
-h | --help)
usage
exit 0
;;
*)
die "Unknown option: $1 (use --help)"
;;
esac
done
}
log() { printf "[%s] %s\n" "$SCRIPT_NAME" "$*" >&2; }
die() {
printf "[%s] ERROR: %s\n" "$SCRIPT_NAME" "$*" >&2
exit 1
}
vlog() { if [[ $VERBOSE -eq 1 ]]; then printf "[%s][verbose] %s\n" "$SCRIPT_NAME" "$*" >&2; fi; }
for cmd in curl jq awk sed grep sort lspci free uname; do
require_cmd "$cmd"
done
HAS_TIMEOUT=0
if command -v timeout > /dev/null 2>&1; then
HAS_TIMEOUT=1
fi
# --------------------------- System detection ---------------------------
SYSTEM_CPU_MODEL=""
SYSTEM_CPU_CLASS="unknown"
SYSTEM_GPU_VENDOR="unknown"
SYSTEM_RAM_GB=0
SYSTEM_ARCH="$(uname -m || echo unknown)"
# --------------------------- Steam data ---------------------------
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/steam-compat-check"
CONFIG_FILE="$CONFIG_DIR/credentials.conf"
# Cache for analyzed results
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/steam-compat-check"
RESULTS_CACHE="$CACHE_DIR/results.tsv"
STEAM_DIRS=("$HOME/.steam/steam" "$HOME/.local/share/Steam")
declare -A CACHE_MAP
# --------------------------- ProtonDB integration ---------------------------
main "$@"