Skip to main content

wrapper_script_contents

Function wrapper_script_contents 

Source
pub fn wrapper_script_contents() -> String
Expand description

Builds the POSIX shell wrapper that Steam invokes on Linux native launches.

Steam launch options are a single fixed %command% string, so a file must sit between Steam and the game. Steam also stores exactly one such string per game, so this script is written once and must stay correct for every target afterwards. It therefore carries no target of its own — nothing about it is specific to a profile, which is why it never needs regenerating:

  • --ts-target <dir> (WRAPPER_TARGET_FLAG) anywhere in the argv Steam forwards selects that directory. launch_plan_in appends it for the caller, so switching targets needs no change to the script or to Steam.
  • Absent that flag — a bare launch straight from Steam, with no manager involved — the game starts unmodded. There is no default profile: a wrapper that quietly loaded one would make “launch from Steam” mean whichever target happened to be baked in, which is the ambiguity this whole mechanism exists to remove. A value that names something other than a directory is likewise treated as no target at all rather than chainloaded blindly, so a deleted profile yields a vanilla launch, not a broken one.

This matches r2modman’s linux_wrapper.sh — which reads --r2profile from argv and launches vanilla without it — with one deliberate difference: it passes a profile name and rebuilds <root>/profiles/<name>, assuming the r2modman layout, whereas this takes a resolved absolute directory and so also serves a bare target such as a dedicated server’s game directory.

The flag and its value are consumed here, never forwarded; every other argument reaches the loader script in its original order, quoted, so a target or game argument containing spaces survives.

The branches are generated from LOADER_SCRIPTS, the same list the resolver behind launch_plan_in searches, so the wrapper and the plan cannot disagree about which scripts count. Falls through to exec "$@" — a vanilla launch — when the resolved target ships none of them.