Skip to content

Game Wrapper (sdy)

dlucca1986 edited this page Apr 29, 2026 · 9 revisions

Version License: MIT Code Style: PEP8 Language: Python

This page outlines the execution wrapper responsible for process interception and dynamic environment injection.


๐Ÿง  Discovery Logic

When sdy %command% is executed, the script performs a hierarchical search for a configuration profile in ~/.config/steamos_diy/games.d/:

  1. Steam AppID: If SteamAppId is present, it scans YAML files for a matching STEAM_APPID or SDY_ID.
  2. Path-Based Discovery (Climbing Logic): If no ID matches, sdy identifies the executable path and performs an upward search (up to 3 directory levels). It attempts to match:
    • The executable filename (e.g., Cyberpunk2077.yaml).
    • The parent directory name (to handle generic launchers like start.exe).
  3. Exclusion: The engine automatically ignores common system/bin folders (bin, x64, common) during the search.

๐Ÿ› ๏ธ Configuration Hierarchy

sdy.py merges configurations using a cascading priority system. Values defined at lower levels are overridden by higher levels:

  1. System Defaults: /etc/default/steamos_diy.conf
  2. Global User Manifesto: ~/.config/steamos_diy/config.yaml
  3. Game-Specific Profile: .yaml file found in games.d/.

Mapping Table

Key Type Description
GAME_WRAPPER Execution Prefix Prepended to the command (e.g., gamemoderun).
GAME_EXTRA_ARGS Flags Appended to the end of the command.
env_vars Dictionary Environment variables injected into the process.

๐Ÿ›ก๏ธ Atomic Execution

To maintain a clean process tree, sdy uses os.execvpe. The launcher process is replaced by the game process, ensuring that the GAME_WRAPPER becomes the direct parent of the game.

# Construction of the final command list
full_cmd = shlex.split(str(wrapper)) if wrapper else []
full_cmd.extend(raw_args)
if extra:
    full_cmd.extend(shlex.split(str(extra)))

# Process replacement
os.execvpe(executable, full_cmd, os.environ)

YAML Resilience: If a game-specific YAML contains syntax errors, load_yaml_safe catches the exception, logs a YAML_PARSE_ERR, and defaults to the global configuration, ensuring the game launches regardless of profile corruption.


๐Ÿ› ๏ธ Usage in Steam

To enable the wrapper for any game:

  • Right-click the game in Steam โž” Properties.

  • In Launch Options, paste:

    sdy %command%

๐Ÿ“Š Logging Output

To verify if sdy has correctly identified your game and applied the right config, check the centralized log via the Control Center or the system journal.

Real-world Log Example: STEAM: Profile via AppID [1091500] -> cyberpunk.yaml STEAM: EXEC: mangohud gamemoderun Cyberpunk2077...

Log Component Description
STEAM The primary tag for game discovery and launch events.
Profile via AppID Indicates a successful match using the Steam AppID.
Profile Loaded by Name Indicates a match found via Executable or Folder name climbing.
EXEC Shows the final command being executed, including wrappers and extra arguments.

Tip

If a profile is not found after the 3-level directory climb, the script will skip the "Profile Loaded" message and proceed using only the global environment variables defined in config.yaml.


โฌ…๏ธ Back to Home.

๐Ÿ—๏ธ Core & Setup

๐ŸŽฎ Gaming

๐Ÿ› ๏ธ Tools & Support


๐Ÿ”— Resources


๐Ÿค Join the Project

If you love this project, feel free to join and help me make it better!

Clone this wiki locally