Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

39.5 KB
Raw Blame
#!/usr/bin/env bash
# Starts every launcher Soju supports (Battle.net, Steam, Epic, GOG, EA, Rockstar, Ubisoft) and stops their bottles.
# It began as the Diablo II: Resurrected launcher; that verified combination is below.
#
# Stack: self-built wine 11.0 (CrossOver 26.3 GPL sources) + D3DMetal (Apple GPTK)
# Verified 2026-08-27: Battle.net login / Agent / D2R in-game.
#
# The three keys (finding these took days):
#  1) ROSETTA_ADVERTISE_AVX=1: D2R's loader requires AVX. Without it the game
#     waits forever (stuck at ~86MB RAM).
#  2) D3DMetal symlink layout: real files in lib/external, symlinks in
#     x86_64-unix. Copying breaks @loader_path and causes an assertion loop
#     (frankea's README warns about this).
#  3) Never put Apple-protected binaries (nohup/arch, ...) in the launch chain:
#     macOS strips DYLD_* when exec'ing them.
set -euo pipefail

ENGINE="${ENGINE:-${SOJU_BASE:-$HOME/.battlenet-macos}/cx26-engine}"
MODE="${1:-battlenet}"

# Check before copying launcher files, changing input sources or starting Wine.
# The unified library launches D2R through Battle.net's OSI product code.
source "$(dirname "${BASH_SOURCE[0]}")/d2r-macos.sh"
D2R_REQUEST=0
case "$MODE" in
  d2r) D2R_REQUEST=1 ;;
  battlenet)
    for argument in "${@:2}"; do
      case "$argument" in '--exec=launch '[Oo][Ss][Ii]) D2R_REQUEST=1 ;; esac
    done ;;
esac
if [ "$MODE" = battlenet ] || [ "$D2R_REQUEST" = 1 ]; then
  if ! macos_check=$(soju_d2r_macos_check); then
    echo "soju: $macos_check" >&2
    [ "$D2R_REQUEST" = 0 ] || exit 1
    echo "      Battle.net can still open for other games. D2R started inside Battle.net has the same macOS requirement." >&2
  fi
fi
source "$(dirname "${BASH_SOURCE[0]}")/steam-runtime.sh"

# Bottle (virtual C: drive) path: per-mode default (Battle.net and Steam use separate bottles)
if [[ "$MODE" == steam* ]]; then
  # soju steam-gptk on: Steam runs from its own bottle on the GPTK engine (scripts/steam-gptk.sh).
  if [ -z "${WINEPREFIX:-}" ] && [ "$(bash "$(dirname "${BASH_SOURCE[0]}")/steam-gptk.sh" status 2>/dev/null)" = on ]; then
    SOJU_STEAM_GPTK=1
    export WINEPREFIX="${SOJU_BASE:-$HOME/.battlenet-macos}/steam-gptk-bottle"
  fi
  export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/steam-bottle}"
elif [[ "$MODE" == epic* ]]; then
  export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/epic-bottle}"
elif [[ "$MODE" == gog* ]]; then
  export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/gog-bottle}"
elif [[ "$MODE" =~ ^(ea|rockstar|ubisoft)(-kill)?$ ]]; then
  export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/${MODE%-kill}-bottle}"
else
  export WINEPREFIX="${WINEPREFIX:-${SOJU_BASE:-$HOME/.battlenet-macos}/bottle}"
fi
# Unreal Engine games that ran here before start without the "Known issues with graphics driver" window
# that otherwise holds them at start (scripts/ue_driver_warning.py).
case "$MODE" in *-kill|kill|controllers) ;; *) python3 "$(dirname "${BASH_SOURCE[0]}")/ue_driver_warning.py" "$WINEPREFIX" >/dev/null 2>&1 || true ;; esac

# The EA app, Rockstar Games Launcher and Ubisoft Connect run on the launcher
# engine: the CX engine plus a Mac driver and DXMT that let their browser UIs
# present across processes (scripts/launcher-engine.sh). The others keep $ENGINE.
case "$MODE" in
  ea-kill|rockstar-kill|ubisoft-kill)
    ENGINE="${SOJU_LAUNCHER_ENGINE:-${SOJU_BASE:-$HOME/.battlenet-macos}/cx26-engine-launchers}" ;;
  ea|rockstar|ubisoft)
    ENGINE=$(SOJU_CX_ENGINE="$ENGINE" bash "$(dirname "${BASH_SOURCE[0]}")/launcher-engine.sh") || exit 1 ;;
esac

# NVIDIA DLSS in D3DMetal games, done by Apple's MetalFX (scripts/gptk-dlss.sh): games that offer DLSS list it
# in their settings. SOJU_DLSS=0 leaves it off. A launcher already running keeps its old environment.
# Called once the Wine environment below is exported: the script may start the bottle's wineserver (wine reg),
# and a server started without WINEMSYNC=1 turns away the launcher that comes after it (msync_init fails).
dlss_on() {
  [ "${SOJU_DLSS:-1}" = 1 ] || return 0
  bash "$(dirname "${BASH_SOURCE[0]}")/gptk-dlss.sh" "$ENGINE" "$WINEPREFIX" && export D3DM_ENABLE_METALFX=1
  return 0
}

export WINEDEBUG="${WINEDEBUG:-fixme-all}"
# SOJU_KEYLOG=1: record every key event the Mac driver sees and every focus
# change, to ~/.battlenet-macos/logs/keys-<mode>-<time>.log. For "a key stays
# pressed" / "keyboard dead, mouse fine" reports: the log shows which window a
# KEY_RELEASE went to. Noisy (mouse moves too); leave it off otherwise.
if [[ "${SOJU_KEYLOG:-0}" == 1 ]]; then
  mkdir -p "${SOJU_BASE:-$HOME/.battlenet-macos}/logs"
  KEYLOG="${SOJU_BASE:-$HOME/.battlenet-macos}/logs/keys-$MODE-$(date +%Y%m%d-%H%M%S).log"
  export WINEDEBUG="fixme-all,+key,+event"
  exec 2>>"$KEYLOG"
  echo "soju keylog $(date) mode=$MODE prefix=$WINEPREFIX" >&2
  echo "soju: key log -> $KEYLOG"
fi
export WINEMSYNC=1
# soju fps on: Apple's Metal Performance HUD (frame rate, frame time, GPU
# memory) in the corner of every game that draws with Metal, which is all of
# them here (D3DMetal, DXMT). The setting is a file so the app can flip it.
[ -f "${SOJU_BASE:-$HOME/.battlenet-macos}/fps-hud" ] && export MTL_HUD_ENABLED=1
export ROSETTA_ADVERTISE_AVX=1
# Battle.net's CEF renderer CHECKs that VirtualProtect() on a written .data page
# of libcef.dll reports PAGE_READWRITE. Plain wine reports PAGE_WRITECOPY for
# image pages forever (it maps them RW and never tracks the first write), so the
# renderer hits int3 on startup and the login webview stays blank. CrossOver's
# ntdll enables the "simulate writecopy" hack (CW Hack 22996) by default; the
# GPL source only enables it through this env var. See docs/DIAGNOSIS.md.
export WINE_SIMULATE_WRITECOPY=1
export CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal
export CX_GRAPHICS_BACKEND=d3dmetal
export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"

# Agent signature-check fix: sync the signed exe into each versioned subfolder
BN="$WINEPREFIX/drive_c/Program Files (x86)/Battle.net"
if [[ -f "$BN/Battle.net.exe" ]]; then
  for v in "$BN"/Battle.net.[0-9]*; do
    [[ -d "$v" ]] && cp -cf "$BN/Battle.net.exe" "$v/Battle.net.exe" 2>/dev/null || true
  done
fi

REAPER="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/soju-reaper.sh"
SWEEP="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/soju-sweep.sh"   # orphaned-service cleanup
source "$(dirname "${BASH_SOURCE[0]}")/bottle-leftovers.sh"
start_reaper(){
  # Watchdog: reaps game processes that outlive their windows, and shuts the
  # prefix down once everything is closed: so "quit" really means quit.
  # Processes left from a session whose wineserver died would run beside the new one.
  bottle_clear_orphans "$WINEPREFIX"
  pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 && return 0
  [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$ENGINE/bin/wineserver" >/dev/null 2>&1 & )
  return 0   # a missing reaper must not abort the launch (set -e)
}

# A Korean/Japanese/Chinese IME swallows key presses in Wine games, and macOS
# remembers the input source per app, so switch to ABC before launching.
case "$MODE" in *-kill) ;; *) python3 "$(dirname "${BASH_SOURCE[0]}")/soju-input-abc.py" 2>/dev/null || true ;; esac

# Command+C / V / A / Z inside Windows programs: Wine's Mac driver sends the
# Command keys as Alt, so nothing copies or pastes (a sign-in form, a chat box)
# and macOS beeps. Map Command to Ctrl, and Option to Alt so Alt-based game
# bindings still work (with both Command keys taken and Option left alone the
# driver has no Alt at all). Written into the bottle's user.reg only while its
# wineserver is down (a live server rewrites the file) and only when absent, so
# setting LeftCommandIsCtrl to "n" in the bottle gives Wine's default back.
# SOJU_COMMAND_IS_CTRL=0 skips it.
case "$MODE" in *-kill|controllers) ;; *)
  if [ "${SOJU_COMMAND_IS_CTRL:-1}" = 1 ] && [ -f "$WINEPREFIX/user.reg" ] \
     && ! grep -q 'LeftCommandIsCtrl' "$WINEPREFIX/user.reg"; then
    srv="$(/usr/bin/stat -L -f "/tmp/.wine-$(id -u)/server-%Xd-%Xi" "$WINEPREFIX" 2>/dev/null || true)"
    if [ -z "$srv" ] || [ ! -S "$srv/socket" ]; then
      printf '\n[Software\\\\Wine\\\\Mac Driver]\n"LeftCommandIsCtrl"="y"\n"RightCommandIsCtrl"="y"\n"LeftOptionIsAlt"="y"\n"RightOptionIsAlt"="y"\n' >> "$WINEPREFIX/user.reg"
    fi
  fi ;;
esac
# DLSS after the keys above: its first run starts the wineserver (wine reg), and the keys are written only while
# no server runs.
case "$MODE" in battlenet|d2r|epic|gog|ea|rockstar|ubisoft) dlss_on ;; esac

# Preflight for the CX engine modes: without the GPTK payload, or with a
# payload whose PE shims are missing (an engine refreshed by an older
# update.sh, which carried only lib/external over), D3D runs on wined3d: the
# Epic launcher crashes at start there, D2R's loader needs libd3dshared to get
# through Rosetta, and everything else is slow. Say so instead of launching.
case "$MODE" in
  battlenet|d2r|epic|gog)
    gptk_ok(){ local f
      [ -f "$ENGINE/lib/external/libd3dshared.dylib" ] || return 1
      for f in d3d11 d3d12 dxgi; do
        grep -q "D3DMetalDLLsBase" "$ENGINE/lib/wine/x86_64-windows/$f.dll" 2>/dev/null || return 1
        [ -L "$ENGINE/lib/wine/x86_64-unix/$f.so" ] || return 1
      done; }
    if ! gptk_ok; then
      if [ -f "$ENGINE/lib/external/libd3dshared.dylib" ]; then
        echo "soju: this engine has the GPTK payload but not Apple's D3D shims (d3d11/d3d12/dxgi.dll), so D3DMetal is not active." >&2
      else
        echo "soju: Apple's Game Porting Toolkit is not installed in this engine, so D3DMetal is not active." >&2
      fi
      echo "      Mount the GPTK dmg (or have CrossOver installed) and run:  $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/soju gptk" >&2
      exit 1
    fi
    # Sony pads (DualShock 4, DualSense; USB or Bluetooth): winebus prefers its
    # raw HID backend for them, and on macOS that backend (IOHID) flags only
    # Xbox pads as gamepads, so a Sony pad comes through as a plain DirectInput
    # device with no XInput slot, which is all Blizzard's games look for (#42).
    # Route Sony's vendor id through SDL instead: the pad is then an Xbox-style
    # XInput controller. Same effect as "Disable hidraw" in the Game Controllers
    # panel, but only for 054C, so wheels and sticks that need raw HID keep it.
    # winebus reads this once when the bottle starts. With the bottle down the
    # entry goes straight into the hive file, so the very next start sees it
    # (`wine reg add` would boot the prefix, and winebus with it, before the
    # value lands); wine only rereads the hive at boot, and a live wineserver
    # rewrites the file, so with the bottle up it goes through reg.exe and
    # applies at the next `soju kill` + start. Only added when the key is
    # absent: set Hidraw to 1 there to get raw HID back for Sony pads.
    if [ -f "$WINEPREFIX/system.reg" ] && ! grep -qi 'Services\\\\winebus\\\\Devices\\\\054C' "$WINEPREFIX/system.reg"; then
      # wine names the server socket directory after the prefix; the socket
      # exists exactly while a wineserver for this prefix is up.
      srv="$(/usr/bin/stat -L -f "/tmp/.wine-$(id -u)/server-%Xd-%Xi" "$WINEPREFIX" 2>/dev/null || true)"
      if [ -n "$srv" ] && [ -S "$srv/socket" ]; then
        "$ENGINE/bin/wine" reg add 'HKLM\System\CurrentControlSet\Services\WineBus\Devices\054C' /v Hidraw /t REG_DWORD /d 0 /f >/dev/null 2>&1 || true
      else
        printf '\n[System\\\\CurrentControlSet\\\\Services\\\\winebus\\\\Devices\\\\054C]\n"Hidraw"=dword:00000000\n' >> "$WINEPREFIX/system.reg"
      fi
    fi ;;
esac

case "$MODE" in
  battlenet)   # Battle.net launcher (log in, then Play for online)
    # Battle.net.exe is started directly, not through "Battle.net Launcher.exe":
    # CrossOver's private compat DB (compatdb-*.dat) injects
    # --in-process-gpu --use-gl=swiftshader for Battle.net.exe. Without them CEF
    # spawns a separate GPU process that dies on init and the frameless main
    # window stays fully transparent (Dock icon, no window). See docs/DIAGNOSIS.md.
    start_reaper
    # Diablo Immortal stops on its loading screen with Wine's own d3dcompiler (#221): give it the one it ships.
    ENGINE="$ENGINE" bash "$(dirname "${BASH_SOURCE[0]}")/own-d3dcompiler.sh" || true
    # By default Battle.net exits when its window is closed (same as Windows).
    # With Settings > "When I close the app" set to the tray (Client.HideOnClose),
    # the window hides instead; a Dock-icon click then starts a second
    # Battle.net.exe, which hands off to the running one and shows its window.
    BN_EXE="C:\\Program Files (x86)\\Battle.net\\Battle.net.exe"
    BN_ARGS="--disable-gpu-compositing --from-launcher --in-process-gpu --use-gl=swiftshader"
    export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '$BN_EXE' $BN_ARGS"
    # Play from the library passes --exec="launch <game>". A Battle.net that is already open takes it and starts
    # the game; one that is just starting drops it and stops at its own Play button (seen 2026-11-22: signed in,
    # "What's New?" on top, no LaunchBinary in its log). So after a cold start the same request is sent again once
    # Battle.net's log says it is signed in, until the log shows the game being launched. Someone who has to type
    # a password first gets the game right after signing in, without pressing Play again.
    BN_COLD=0
    pgrep -f 'Battle\.net\.exe' >/dev/null 2>&1 || BN_COLD=1
    if [[ " ${*:2} " == *" --exec="* ]] && [ "$BN_COLD" = 1 ]; then
      BN_MARK="$WINEPREFIX/.soju-launch-mark"; : > "$BN_MARK"
      (
        sent=0; last=0
        for tick in $(seq 1 120); do               # ten minutes
          sleep 5
          [ "$tick" -lt 4 ] || pgrep -f 'Battle\.net\.exe' >/dev/null 2>&1 || exit 0   # Battle.net was closed
          logs=$(find "$WINEPREFIX/drive_c/users"/*/AppData/Local/Battle.net/Logs -name 'battle.net-*.log' -newer "$BN_MARK" 2>/dev/null)
          [ -n "$logs" ] || continue
          if echo "$logs" | tr '\n' '\0' | xargs -0 grep -qa 'LaunchBinary: uid=' 2>/dev/null; then exit 0; fi
          echo "$logs" | tr '\n' '\0' | xargs -0 grep -qa 'Logged into Battle.net successfully' 2>/dev/null || continue
          [ "$sent" -lt 4 ] || exit 0
          [ $((tick - last)) -ge 6 ] || continue   # half a minute between tries
          "$ENGINE/bin/wine" "$BN_EXE" $BN_ARGS "${@:2}" >/dev/null 2>&1 || true
          sent=$((sent + 1)); last=$tick
        done
      ) >/dev/null 2>&1 &
    fi
    # Then follow the start in Battle.net's own log (scripts/battlenet_launch.py): quiet when the game starts;
    # a sign-in, an update first, or a game Battle.net thinks is still running is shown and said.
    BN_UID=$(printf '%s\n' "${@:2}" | sed -n 's/^--exec=launch \(.*\)$/\1/p' | head -1)
    if [ -n "$BN_UID" ]; then
      export SOJU_BNET_SHOW="/bin/bash"$'\x1f'"${BASH_SOURCE[0]}"$'\x1f'"battlenet"
      BN_WATCH=(python3 "$(dirname "${BASH_SOURCE[0]}")/battlenet_launch.py" watch "$WINEPREFIX" "$BN_UID")
      if [ "$BN_COLD" = 1 ]; then
        ( "$ENGINE/bin/wine" "$BN_EXE" $BN_ARGS "${@:2}" & )
        exec "${BN_WATCH[@]}" --seconds 150
      fi
      exec "${BN_WATCH[@]}" -- "$ENGINE/bin/wine" "$BN_EXE" $BN_ARGS "${@:2}"
    fi
    exec "$ENGINE/bin/wine" "$BN_EXE" $BN_ARGS "${@:2}"
    ;;
  d2r)         # Launch the game directly (offline / previous session)
    start_reaper
    cd "$WINEPREFIX/drive_c/Program Files (x86)/Diablo II Resurrected"
    exec "$ENGINE/bin/wine" "D2R.exe" "${@:2}"
    ;;
  epic)        # Epic Games Launcher, same engine and env as Battle.net (verified 2026-08-29)
    # Runs as-is: Epic's CEF (EpicWebHelper) keeps its GPU process alive here,
    # so none of the Battle.net command-line switches are needed.
    # Closing the window hides it, exactly like on Windows: Epic's tray icon
    # lands in the macOS menu bar (winemac systray -> NSStatusItem); a
    # double-click or the right-click menu there reopens it. Do NOT force the
    # hidden window back via ShowWindow()/SC_RESTORE from outside: Slate keeps
    # its "minimized" state and the window comes back unresponsive. A Dock-icon
    # click therefore replays the tray double-click into the launcher instead
    # (tools/soju-epic-restore.c, built by create-epic-bottle.sh).
    export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '${SOJU_BASE:-$HOME/.battlenet-macos}/epic-support/soju-epic-restore.exe'"
    # The EOS overlay (EOSOVH-*-Shipping.dll, loaded by the EOS SDK into every
    # game, plus a CEF renderer tree beside it) is off by default, like Steam's
    # gameoverlayrenderer. It draws inside the game's own process, so when one
    # of its windows takes Wine's keyboard focus (a toast, an achievement) the
    # game gets no deactivation: a movement key held at that moment stays down,
    # and every key after it goes to the overlay while the mouse keeps working
    # (mouse input follows the cursor, keyboard input follows the foreground
    # window). Under Wine the overlay offers nothing but those toasts. Wine
    # honours the override for a load by full path too (verified with
    # regsvr32: "Failed to load DLL"). SOJU_EPIC_OVERLAY=1 turns it back on.
    # A launcher already running keeps its old environment: soju epic-kill first.
    if [[ "${SOJU_EPIC_OVERLAY:-0}" != 1 ]]; then
      export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:+$WINEDLLOVERRIDES;}EOSOVH-Win64-Shipping,EOSOVH-Win32-Shipping=d"
    fi
    EPIC="C:\\Program Files\\Epic Games\\Launcher\\Portal\\Binaries\\Win64\\EpicGamesLauncher.exe"
    [[ -f "$WINEPREFIX/drive_c/Program Files/Epic Games/Launcher/Portal/Binaries/Win64/EpicGamesLauncher.exe" ]] || \
      { echo "Epic Games Launcher not found, run scripts/create-epic-bottle.sh first"; exit 1; }
    pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 || \
      { [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$ENGINE/bin/wineserver" epic >/dev/null 2>&1 & ); }
    exec "$ENGINE/bin/wine" "$EPIC" "${@:2}"
    ;;
  epic-kill)   # Stop everything in the Epic bottle
    pkill -f "soju-reaper.sh $WINEPREFIX" 2>/dev/null || true
    "$ENGINE/bin/wineserver" -k 2>/dev/null || true
    bottle_kill_leftovers "$WINEPREFIX" || true
    sleep 2; [ ! -x "$SWEEP" ] || "$SWEEP"
    ;;
  gog)         # GOG GALAXY, same engine and env as Battle.net (verified 2026-08-30)
    # GOG GALAXY 2.x is Qt6 + QtWebEngine. Its D3D11 compositing path needs
    # IDXGIResource, which D3DMetal's DXGI does not implement, so the window
    # stays black unless Chromium runs on the CPU (--disable-gpu). GOG
    # overwrites QTWEBENGINE_CHROMIUM_FLAGS itself and ignores its argv, so the
    # engine's kernelbase/ucrtbase hook appends SOJU_CHROMIUM_FLAGS to that
    # variable whenever the program sets it (patches/chromium-flags-append.patch).
    # Closing the window parks GOG in the tray (macOS menu bar icon).
    GOG="C:\\Program Files\\GOG Galaxy\\GalaxyClient.exe"
    [[ -f "$WINEPREFIX/drive_c/Program Files/GOG Galaxy/GalaxyClient.exe" ]] || \
      { echo "GOG GALAXY not found, run scripts/create-gog-bottle.sh first"; exit 1; }
    rm -f "$WINEPREFIX/drive_c/ProgramData/GOG.com/Galaxy/lock-files/"* 2>/dev/null || true
    pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 || \
      { [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$ENGINE/bin/wineserver" gog >/dev/null 2>&1 & ); }
    export SOJU_CHROMIUM_FLAGS="${SOJU_CHROMIUM_FLAGS:---disable-gpu --disable-gpu-compositing}"
    export WINE_NO_DOCK_ICON="QtWebEngineProcess.exe;GalaxyClientService.exe;GOG Galaxy Notifications Renderer.exe;GalaxyCommunication.exe;GalaxyClientHelper.exe"
    # GOG draws its own title bar inside the client area; a macOS title bar on
    # top would hide the first rows of its UI (winemac patch: WINE_CUSTOM_FRAME).
    export WINE_CUSTOM_FRAME="GalaxyClient.exe"
    # Closing the window parks GOG in the tray. A Dock-icon click (winemac
    # patch: WINE_DOCK_REOPEN_CMD runs when no window is visible) sends the
    # same WM_COPYDATA "restore" message a second GalaxyClient.exe instance
    # would send, without paying for a whole second client start-up
    # (tools/soju-gog-restore.c, built by create-gog-bottle.sh).
    export WINE_DOCK_REOPEN_CMD="'$ENGINE/bin/wine' '${SOJU_BASE:-$HOME/.battlenet-macos}/gog-support/soju-gog-restore.exe'"
    exec python3 "$(dirname "${BASH_SOURCE[0]}")/gog-launch.py" "$ENGINE/bin/wine" "$GOG" "${@:2}"
    ;;
  gog-kill)    # Stop everything in the GOG bottle
    pkill -f "soju-reaper.sh $WINEPREFIX" 2>/dev/null || true
    "$ENGINE/bin/wineserver" -k 2>/dev/null || true
    bottle_kill_leftovers "$WINEPREFIX" || true
    sleep 2; [ ! -x "$SWEEP" ] || "$SWEEP"
    ;;
  ea|rockstar|ubisoft)   # EA app, Rockstar Games Launcher, Ubisoft Connect (verified 2026-11-10)
    # Installed by create-launcher-bottle.sh. Closing a window parks EA and
    # Ubisoft in the menu bar (tray); Rockstar quits.
    case "$MODE" in
      ea)       CLIENT='Program Files/Electronic Arts/EA Desktop/EA Desktop/EADesktop.exe'
                # "EA Desktop\EA Desktop" is a junction only Wine resolves (the
                # EA app's updater moves it): check for any installed version.
                compgen -G "$WINEPREFIX/drive_c/Program Files/Electronic Arts/EA Desktop/*/EA Desktop/EADesktop.exe" >/dev/null \
                  || { echo "Not installed yet, run: soju ea-install"; exit 1; } ;;
      rockstar) CLIENT='Program Files/Rockstar Games/Launcher/Launcher.exe' ;;
      ubisoft)  CLIENT='Program Files (x86)/Ubisoft/Ubisoft Game Launcher/UbisoftConnect.exe' ;;
    esac
    [[ "$MODE" = ea || -f "$WINEPREFIX/drive_c/$CLIENT" ]] || { echo "Not installed yet, run: soju $MODE-install"; exit 1; }
    pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 || \
      { [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$ENGINE/bin/wineserver" "$MODE" >/dev/null 2>&1 & ); }
    exec "$ENGINE/bin/wine" "C:\\${CLIENT//\//\\}" "${@:2}"
    ;;
  ea-kill|rockstar-kill|ubisoft-kill)   # Stop everything in that launcher's bottle
    pkill -f "soju-reaper.sh $WINEPREFIX" 2>/dev/null || true
    "$ENGINE/bin/wineserver" -k 2>/dev/null || true
    bottle_kill_leftovers "$WINEPREFIX" || true
    sleep 2; [ ! -x "$SWEEP" ] || "$SWEEP"
    ;;
  steam)       # Steam client, wine-stable + webhelper wrapper (verified 2026-08-27)
    # Steam's CEF does not render on the CX engine (black screen / SEGV storm).
    # The verified combination is Homebrew wine-stable 11 + the steamwebhelper
    # wrapper (forces --disable-gpu --single-process) + -no-cef-sandbox
    # -cef-single-process. Source: github.com/notpop/steam-on-m1-wine (MIT),
    # vendored in third_party/.
    # Count games started from Steam's own window too (play counts; does nothing when they are off,
    # and only one watcher runs however often Steam is opened).
    ( nohup python3 "$(dirname "${BASH_SOURCE[0]}")/play-stats.py" watch >/dev/null 2>&1 & )
    # Play on a game while Steam is open: Steam takes the request and may refuse it (no licence, offline) or wait
    # for an answer in its window, which may be hidden. Follow Steam's own log for that game and say so
    # (scripts/steam_launch.py); a start that goes through ends quietly. A cold start is Steam itself, so not here.
    # When Steam is not open yet, Steam starts in the background and the same watch follows the start, a
    # little longer, so a sign-in or a question in Steam's window is shown rather than waited on unseen.
    STEAM_WATCH=(); STEAM_COLD=0
    STEAM_APP=$(printf '%s\n' "${@:2}" | sed -n 's#^steam://rungameid/\([0-9][0-9]*\)$#\1#p' | head -1)
    # A second hand-off from steam_launch.py (Steam had not taken up the first): the first watch follows it.
    [ "${SOJU_STEAM_RESENT:-0}" = 1 ] && STEAM_APP=""
    if [ -n "$STEAM_APP" ]; then
      pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1 || STEAM_COLD=1
      STEAM_WATCH=(python3 "$(dirname "${BASH_SOURCE[0]}")/steam_launch.py" watch "$WINEPREFIX/drive_c/Program Files (x86)/Steam" "$STEAM_APP")
      [ "$STEAM_COLD" = 0 ] || STEAM_WATCH+=(--seconds 150)
      STEAM_WATCH+=(--)
      export SOJU_STEAM_SHOW="/bin/bash"$'\x1f'"${BASH_SOURCE[0]}"$'\x1f'"steam"$'\x1f'"steam://open/main"
      export SOJU_STEAM_RESEND="/bin/bash"$'\x1f'"${BASH_SOURCE[0]}"$'\x1f'"steam"$'\x1f'"steam://rungameid/$STEAM_APP"
    fi
    if [ "${SOJU_STEAM_GPTK:-0}" = 1 ]; then
      # Steam with Apple GPTK: the CX engine plus the cross-process winemac
      # (scripts/steam-gptk-engine.sh). Same wrapper and flags as below; games
      # get D3DMetal like Battle.net games, and no Wine 11 steps apply.
      ENGINE=$(bash "$(dirname "${BASH_SOURCE[0]}")/steam-gptk-engine.sh") || exit 1
      # Rockstar games sold on Steam start the Rockstar Games Launcher in this bottle first. With Apple's D3D11
      # it stops at "The Rockstar Games Launcher failed to initialize!" and Steam then says "Unable to launch
      # game" (#236); on the launcher engine (DXMT's D3D11, D3D12 still D3DMetal) it opens, as in its own
      # bottle. So Steam runs on that engine for these games, restarted if it is open on the other one.
      # .soju-steam-engine says which engine the open Steam runs on (the launcher engine also runs other bottles,
      # so its wineserver alone does not tell).
      STEAM_ON=$(cat "$WINEPREFIX/.soju-steam-engine" 2>/dev/null || true); [ -n "$STEAM_ON" ] || STEAM_ON="$ENGINE"
      STEAM_OPEN=0; pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1 && STEAM_OPEN=1
      case " 1174180 271590 3240220 12210 204100 2668510 1546970 1546990 1547000 " in
        *" ${STEAM_APP:-none} "*) ENGINE=$(bash "$(dirname "${BASH_SOURCE[0]}")/launcher-engine.sh") || exit 1 ;;
        # Opening Steam itself: hand it to Steam on the engine it is open on.
        *) [ -z "$STEAM_APP" ] && [ "$STEAM_OPEN" = 1 ] && [ -x "$STEAM_ON/bin/wine" ] && ENGINE="$STEAM_ON" ;;
      esac
      if [ -n "$STEAM_APP" ] && [ "$STEAM_OPEN" = 1 ] && [ "$STEAM_ON" != "$ENGINE" ]; then
        echo "Restarting Steam for this game: Rockstar games need another graphics setup for their launcher"
        bash "${BASH_SOURCE[0]}" steam-kill >/dev/null 2>&1 || true
        for _ in $(seq 1 30); do pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1 || break; sleep 1; done
        STEAM_COLD=1
        STEAM_WATCH=(python3 "$(dirname "${BASH_SOURCE[0]}")/steam_launch.py" watch "$WINEPREFIX/drive_c/Program Files (x86)/Steam" "$STEAM_APP" --seconds 150 --)
      fi
      printf '%s\n' "$ENGINE" > "$WINEPREFIX/.soju-steam-engine"
      dlss_on
      export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
      export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"
      # The Rockstar Games Library Service starts slowly under Rosetta; Wine stops waiting after 10 s by default
      # (create-launcher-bottle.sh sets the same for the Rockstar bottle).
      if [ ! -f "$WINEPREFIX/.soju-services-timeout" ]; then
        "$ENGINE/bin/wine" reg add 'HKLM\System\CurrentControlSet\Control' /v ServicesPipeTimeout /t REG_SZ /d 60000 /f >/dev/null 2>&1 \
          && : > "$WINEPREFIX/.soju-services-timeout"
      fi
      ST="$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"
      [[ -f "$ST" ]] || { echo "Steam not found in $WINEPREFIX; run: soju steam-gptk on"; exit 1; }
      find "$WINEPREFIX/drive_c/users/"*/AppData/Local/Steam/htmlcache -maxdepth 2 \
        \( -name "Singleton*" -o -name "*.lock" \) -delete 2>/dev/null || true
      # Steam updates put the real steamwebhelper back; without the wrapper the window stays black.
      WRAP="$STEAM_SUPPORT/steamwebhelper-wrapper.exe"
      [ -f "$WRAP" ] || { echo "Steam support files missing; run: soju steam-install"; exit 1; }
      for d in "$WINEPREFIX/drive_c/Program Files (x86)/Steam/bin/cef"/cef.win*; do
        [[ -f "$d/steamwebhelper.exe" ]] || continue
        if [[ $(stat -f%z "$d/steamwebhelper.exe") -gt 500000 ]]; then
          mv -f "$d/steamwebhelper.exe" "$d/steamwebhelper_real.exe"
          cp -f "$WRAP" "$d/steamwebhelper.exe"
        fi
      done
      pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1 || \
        python3 "$(dirname "${BASH_SOURCE[0]}")/steam-profiles.py" options || true
      # NW.js games (RPG Maker MV/MZ) need --in-process-gpu here too; Steam restores package.json on updates.
      python3 "$(dirname "${BASH_SOURCE[0]}")/steam-profiles.py" nwjs || true
      export WINEDLLOVERRIDES="winemenubuilder.exe=;bcrypt=b;ncrypt=b;gameoverlayrenderer,gameoverlayrenderer64=d"
      "$ENGINE/bin/wine" reg delete 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' /v Steam /f >/dev/null 2>&1 || true
      # GoldSrc OpenGL setting (#153), once per bottle; the Wine 11 bottle gets it from setup-steam-games.sh.
      if [ ! -f "$WINEPREFIX/.soju-gl-defaults" ]; then
        bash "$(dirname "${BASH_SOURCE[0]}")/gl-app-defaults.sh" "$ENGINE/bin/wine" && : > "$WINEPREFIX/.soju-gl-defaults"
      fi
      pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 || \
        { [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$ENGINE/bin/wineserver" steam >/dev/null 2>&1 & ); }
      STEAM_CMD=("C:\\Program Files (x86)\\Steam\\steam.exe" -no-cef-sandbox -cef-single-process)
      [ -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steamui.dll" ] && STEAM_CMD+=(-noverifyfiles)
      if [ "$STEAM_COLD" = 1 ]; then
        ( "$ENGINE/bin/wine" "${STEAM_CMD[@]}" "${@:2}" & )
        exec "${STEAM_WATCH[@]}"
      fi
      exec ${STEAM_WATCH[@]+"${STEAM_WATCH[@]}"} "$ENGINE/bin/wine" "${STEAM_CMD[@]}" "${@:2}"
    fi
    WINESTABLE="$STEAM_WINE_ROOT/bin/wine"
    WINESTABLE_SERVER="$STEAM_WINE_ROOT/bin/wineserver"
    [[ -x "$WINESTABLE" ]] || { echo "Steam runtime not found. Reinstall Steam from Stores or run: soju steam-install"; exit 1; }
    ST="$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"
    [[ -f "$ST" ]] || { echo "Steam not found, run scripts/create-steam-bottle.sh first"; exit 1; }
    # A newer Steam support package (resources/steam-support.json) is set up before Steam
    # starts, so an app update brings its components without Update components.
    # steam-session.py idle looks at running wineservers themselves (the reaper's command line names the
    # server path too, so pgrep -f on it is never empty while the reaper runs).
    if [ -f "$STEAM_WINE_ROOT/.soju-runtime" ] && \
       python3 "$(dirname "${BASH_SOURCE[0]}")/steam-session.py" idle "$STEAM_WINE_ROOT" >/dev/null 2>&1; then
      want=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' \
        "$(dirname "${BASH_SOURCE[0]}")/../resources/steam-support.json" 2>/dev/null || true)
      if [ -n "$want" ] && [ "$(cat "$STEAM_WINE_ROOT/.soju-runtime")" != "$want" ]; then
        echo "Updating Steam components to $want"
        bash "$(dirname "${BASH_SOURCE[0]}")/setup-steam-games.sh" || echo "soju: Steam component update failed; Steam starts with the previous ones" >&2
      fi
    fi
    # Vulkan games through MoltenVK: compile shaders on every core and keep their source compressed
    # (Detroit: Become Human prepares thousands of pipelines on its first start).
    export MVK_CONFIG_SHOULD_MAXIMIZE_CONCURRENT_COMPILATION=1 MVK_CONFIG_SHADER_COMPRESSION_ALGORITHM=1
    # Repair a bootstrap-only installation before deploying the CEF wrapper.
    python3 "$(dirname "${BASH_SOURCE[0]}")/bootstrap-steam.py" "$WINESTABLE"
    # Known DXVK games (resources/steam-profiles.json) get DXVK once, before Steam
    # starts; the renderer switch refuses while this bottle is running anyway.
    pgrep -f "$WINESTABLE_SERVER" >/dev/null 2>&1 || \
      python3 "$(dirname "${BASH_SOURCE[0]}")/steam-profiles.py" apply || true
    # Launch options known games need (resources/steam-launch-options.json): only while Steam is closed,
    # since Steam writes its config back when it quits.
    pgrep -f "$WINESTABLE_SERVER" >/dev/null 2>&1 || \
      python3 "$(dirname "${BASH_SOURCE[0]}")/steam-profiles.py" options || true
    # NW.js games (RPG Maker MV/MZ) need --in-process-gpu or their window stays empty;
    # Steam restores package.json on updates, so check every launch.
    python3 "$(dirname "${BASH_SOURCE[0]}")/steam-profiles.py" nwjs || true
    # 1) Clean crash leftovers (a stale lock makes the next launch a windowless --silent one)
    find "$WINEPREFIX/drive_c/users/"*/AppData/Local/Steam/htmlcache -maxdepth 2 \
      \( -name "Singleton*" -o -name "*.lock" \) -delete 2>/dev/null || true
    # 2) Redeploy the wrapper (Steam updates restore the original, so check every launch)
    WRAP="$STEAM_SUPPORT/steamwebhelper-wrapper.exe"
    for d in "$WINEPREFIX/drive_c/Program Files (x86)/Steam/bin/cef"/cef.win*; do
      [[ -f "$d/steamwebhelper.exe" ]] || continue
      if [[ $(stat -f%z "$d/steamwebhelper.exe") -gt 500000 ]]; then
        mv -f "$d/steamwebhelper.exe" "$d/steamwebhelper_real.exe"
        cp -f "$WRAP" "$d/steamwebhelper.exe"
      fi
    done
    # 3) Keep virtual-desktop windows movable (one-time registry setting).
    #    Done before anything boots the prefix: a live wineserver rewrites
    #    user.reg on exit and would drop a line appended underneath it.
    if ! pgrep -x wineserver >/dev/null 2>&1; then
      grep -q 'AllowImmovableWindows' "$WINEPREFIX/user.reg" 2>/dev/null || {
        printf '\n[Software\\\\Wine\\\\Mac Driver]\n"AllowImmovableWindows"="n"\n' >> "$WINEPREFIX/user.reg"
      }
    fi
    # Everything that touches the Steam prefix runs without the CX engine
    # environment (wine-stable has its own dylibs and no msync), the first
    # process included: it is the one that boots the wineserver.
    STEAM_ENV=(env -u DYLD_FALLBACK_LIBRARY_PATH -u CX_ACTIVE_GRAPHICS_BACKEND -u CX_GRAPHICS_BACKEND
               -u CX_APPLEGPTK_LIBD3DSHARED_PATH -u WINEMSYNC -u ROSETTA_ADVERTISE_AVX -u WINE_SIMULATE_WRITECOPY
               WINEPREFIX="$WINEPREFIX" WINEDEBUG="${WINEDEBUG:-fixme-all}")
    # GStreamer for WMA voice lines (scripts/fetch-gstreamer.py, #94). winegstreamer
    # looks for @rpath/libgst*; the fallback path is only searched when its own lookups fail.
    GST="${SOJU_BASE:-$HOME/.battlenet-macos}/gstreamer"
    if [ -f "$GST/.soju-gstreamer" ]; then
      STEAM_ENV+=(DYLD_FALLBACK_LIBRARY_PATH="$GST/lib:/usr/lib" GST_PLUGIN_SYSTEM_PATH_1_0="$GST/lib/gstreamer-1.0"
                  GST_PLUGIN_SCANNER_1_0="$GST/libexec/gstreamer-1.0/gst-plugin-scanner" GST_REGISTRY_1_0="$GST/registry.x86_64.bin")
    fi
    # 4) Drop Steam's autostart entry. Steam adds itself to the prefix's Run key
    #    with -silent, so it comes back invisibly whenever anything boots this
    #    prefix. Steam re-adds it on update, so scrub it every launch.
    "${STEAM_ENV[@]}" "$WINESTABLE" reg delete 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' \
      /v Steam /f >/dev/null 2>&1 || true
    # 5) Keep steam.exe away from Core Audio (#55). Wine 11.0's winmm builds its
    #    device list by asking every device about 20 PCM formats, and each ask
    #    opens a Core Audio unit on that device. Steam does this from its main
    #    loop (mixerOpen), so a slow device stalls the client before its login
    #    window: 0.1 s with two outputs, 0.7-1.7 s once microphones are present,
    #    and past Steam's 15 s stall check on one reported Mac. Wine 11.5 dropped
    #    the probe (c3a1bc8613). Only steam.exe is affected: games, and the
    #    webhelper that plays store videos, keep their sound. Added only when
    #    absent, so setting the value to "builtin" gives Steam its audio back.
    STEAM_AUDIO_KEY='HKCU\Software\Wine\AppDefaults\steam.exe\DllOverrides'
    "${STEAM_ENV[@]}" "$WINESTABLE" reg query "$STEAM_AUDIO_KEY" /v winecoreaudio.drv >/dev/null 2>&1 ||
      "${STEAM_ENV[@]}" "$WINESTABLE" reg add "$STEAM_AUDIO_KEY" /v winecoreaudio.drv /t REG_SZ /d disabled /f \
        >/dev/null 2>&1 || true
    # 6) Virtual desktop: this macdrv (gcenx wine 11) ignores virtual desktops,
    #    so it is off by default. The single Dock icon is handled by
    #    WINE_NO_DOCK_ICON (winemac patch) instead.
    #    To enable anyway: WINE_VIRTUAL_DESKTOP=auto (or a resolution like 1600x900).
    VD="${WINE_VIRTUAL_DESKTOP-}"
    if [[ "$VD" == "auto" ]]; then
      B=$(osascript -e 'tell application "Finder" to get bounds of window of desktop' 2>/dev/null || true)
      if [[ "$B" =~ ,[[:space:]]*([0-9]+),[[:space:]]*([0-9]+)$ ]]; then
        VD="${BASH_REMATCH[1]}x${BASH_REMATCH[2]}"
      else
        VD="1728x1080"
      fi
    fi
    # 7) Launch: plain wine-stable environment, without the CX engine env
    STEAM_CMD=("C:\\Program Files (x86)\\Steam\\steam.exe" -no-cef-sandbox -cef-single-process)
    # SteamSetup only contains the bootstrapper: let first launch download the
    # client, otherwise Steam fails with "Failed to load steamui.dll".
    if [ -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steamui.dll" ]; then
      STEAM_CMD+=(-noverifyfiles)
    fi
    STEAM_CMD+=("${@:2}")
    [[ -n "$VD" ]] && STEAM_CMD=(explorer.exe "/desktop=soju-steam,$VD" "${STEAM_CMD[@]}")
    # Closing the Steam window parks it in a tray macOS does not show; the patched
    # winemac runs WINE_DOCK_REOPEN_CMD on a Dock-icon click when no window is
    # visible, which makes the running Steam show its window again (same UX as
    # Windows' tray icon).
    # Reaper in steam mode: once Steam itself exits (Steam menu > Exit), tear the
    # rest of the bottle down so no Dock icon / winedevice lingers.
    pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 || \
      { [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$WINESTABLE_SERVER" steam >/dev/null 2>&1 & ); }
    STEAM_RUN=("${STEAM_ENV[@]}" 
      WINEDLLOVERRIDES="bcrypt=b;ncrypt=b;gameoverlayrenderer,gameoverlayrenderer64=d" 
      WINE_NO_DOCK_ICON="steam.exe;steamservice.exe" 
      WINE_DOCK_REOPEN_CMD="'$WINESTABLE' 'C:\\Program Files (x86)\\Steam\\steam.exe' steam://open/main" 
      "$WINESTABLE" "${STEAM_CMD[@]}")
    if [ "$STEAM_COLD" = 1 ]; then
      ( "${STEAM_RUN[@]}" & )
      exec "${STEAM_WATCH[@]}"
    fi
    exec ${STEAM_WATCH[@]+"${STEAM_WATCH[@]}"} "${STEAM_RUN[@]}"
    ;;
  controllers) # Game Controllers panel of the Battle.net bottle (Wine's joy.cpl):
    # shows what the bottle sees (DirectInput, XInput slots) and the SDL/hidraw
    # toggles. The bottle shuts down when the panel closes if nothing else runs
    # in it; a running Battle.net needs `soju kill` for a toggle to apply.
    exec "$ENGINE/bin/wine" control joy.cpl
    ;;
  kill)        # Stop everything in the Battle.net bottle
    pkill -f "soju-reaper.sh $WINEPREFIX" 2>/dev/null || true
    "$ENGINE/bin/wineserver" -k 2>/dev/null || true
    bottle_kill_leftovers "$WINEPREFIX" || true
    sleep 2; [ ! -x "$SWEEP" ] || "$SWEEP"
    ;;
  steam-kill)  # Stop everything in the Steam bottle, note this bottle runs on
    # wine-stable, so it needs wine-stable's wineserver. Killing the CX engine's
    # wineserver here does nothing and leaves steam.exe alive, which then keeps
    # respawning steamwebhelper (it looks like "Steam relaunches itself").
    # With Steam on GPTK the bottle and engine differ, so stop both kinds.
    S_BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
    for b in "$S_BASE/steam-bottle" "$S_BASE/steam-gptk-bottle"; do pkill -f "soju-reaper.sh $b" 2>/dev/null || true; done
    WINEPREFIX="$S_BASE/steam-bottle" "$STEAM_WINE_ROOT/bin/wineserver" -k 2>/dev/null || true
    [ ! -d "$S_BASE/steam-gptk-bottle" ] || [ ! -x "$S_BASE/cx26-engine-steam/bin/wineserver" ] || \
      WINEPREFIX="$S_BASE/steam-gptk-bottle" "$S_BASE/cx26-engine-steam/bin/wineserver" -k 2>/dev/null || true
    # Steam on the launcher engine for a Rockstar game (see the steam case above).
    [ ! -d "$S_BASE/steam-gptk-bottle" ] || [ ! -x "$S_BASE/cx26-engine-launchers/bin/wineserver" ] || \
      WINEPREFIX="$S_BASE/steam-gptk-bottle" "$S_BASE/cx26-engine-launchers/bin/wineserver" -k 2>/dev/null || true
    for b in "$S_BASE/steam-bottle" "$S_BASE/steam-gptk-bottle"; do [ ! -d "$b" ] || bottle_kill_leftovers "$b" || true; done
    sleep 2; [ ! -x "$SWEEP" ] || "$SWEEP"
    ;;
  *) echo "usage: play.sh [battlenet|d2r|epic|epic-kill|gog|gog-kill|ea|ea-kill|rockstar|rockstar-kill|ubisoft|ubisoft-kill|steam|kill|steam-kill]"; exit 1;;
esac