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.

soju-reaper: steam mode — shut the Steam bottle down once its windows are gone

mikey925794b47dd5e4
diff --git a/README.md b/README.md
index 65fee9df16f..c236813fdf1 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ D2R shipped on Steam in Feb 2026 as the *Infernal Edition*. Steam support uses a
```bash
scripts/create-steam-bottle.sh # installs wine-stable + wrapper + official Valve installer
scripts/play.sh steam # log in -> install & play
-scripts/play.sh steam-kill # stop the Steam bottle
+scripts/play.sh steam-kill # stop the Steam bottle (closing the Steam window also shuts it down after ~40 s)
```
Verified on M4 Pro / macOS 26.5: login, library, and an actual D3D11 (Unity) game rendering in-game via a DXMT fork — see `docs/STEAM-GAMES.md` for the full wiring (`scripts/setup-steam-games.sh`). Notes: switch your macOS input source to English (ABC) when typing in Steam (IME composition shows as `?` otherwise).
diff --git a/scripts/play.sh b/scripts/play.sh
index d3ae99c7e72..39a475e7177 100755
--- a/scripts/play.sh
+++ b/scripts/play.sh
@@ -79,6 +79,7 @@ case "$MODE" in
# -cef-single-process. Source: github.com/notpop/steam-on-m1-wine (MIT),
# vendored in third_party/.
WINESTABLE="/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine"
+ WINESTABLE_SERVER="/Applications/Wine Stable.app/Contents/Resources/wine/bin/wineserver"
[[ -x "$WINESTABLE" ]] || { echo "wine-stable not found — brew install --cask wine-stable"; 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; }
@@ -119,6 +120,10 @@ case "$MODE" in
# 5) 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 -noverifyfiles "${@:2}")
[[ -n "$VD" ]] && STEAM_CMD=(explorer.exe "/desktop=soju-steam,$VD" "${STEAM_CMD[@]}")
+ # Reaper in steam mode: closing the Steam window normally leaves steam.exe
+ # parked in an invisible tray (Dock icon stays). Shut the bottle down instead.
+ pgrep -f "soju-reaper.sh $WINEPREFIX" >/dev/null 2>&1 || \
+ { [ -x "$REAPER" ] && ( "$REAPER" "$WINEPREFIX" "$WINESTABLE_SERVER" steam >/dev/null 2>&1 & ); }
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 \
WINEPREFIX="$WINEPREFIX" WINEDEBUG="${WINEDEBUG:-fixme-all}" \
@@ -134,6 +139,7 @@ case "$MODE" in
# 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").
+ pkill -f "soju-reaper.sh $WINEPREFIX" 2>/dev/null || true
"/Applications/Wine Stable.app/Contents/Resources/wine/bin/wineserver" -k 2>/dev/null || true
;;
*) echo "usage: play.sh [battlenet|d2r|steam|kill|steam-kill]"; exit 1;;
diff --git a/scripts/soju-reaper.sh b/scripts/soju-reaper.sh
index 87ca18518ad..4f6b373d809 100755
--- a/scripts/soju-reaper.sh
+++ b/scripts/soju-reaper.sh
@@ -11,14 +11,29 @@
# Window detection uses CGWindowListCopyWindowInfo via python3+ctypes — no
# Accessibility permission needed, nothing to install.
#
-# Usage: soju-reaper.sh <WINEPREFIX> <wineserver-path> (backgrounded by play.sh)
+# Usage: soju-reaper.sh <WINEPREFIX> <wineserver-path> [battlenet|steam]
+# (backgrounded by play.sh / the Battle.net.app launcher)
+#
+# steam mode: the Windows Steam client never really quits — closing its window
+# just parks it in a tray that macOS does not show, so the Dock icon and half a
+# dozen processes linger. In steam mode "no Steam/game window on screen for two
+# checks" means the user is done: the whole Steam bottle is shut down.
set -u
-PREFIX="${1:?usage: soju-reaper.sh <WINEPREFIX> <wineserver>}"
+PREFIX="${1:?usage: soju-reaper.sh <WINEPREFIX> <wineserver> [battlenet|steam]}"
WINESERVER="${2:?}"
+MODE="${3:-battlenet}"
INTERVAL=20
-GAME_RE='D2R\.exe|BlizzardError\.exe'
-UI_RE='Battle\.net\.exe.*--from-launcher|Battle\.net Launcher\.exe'
+case "$MODE" in
+ steam)
+ GAME_RE='Steam\\steamapps\\' # games live under steamapps
+ UI_RE='steam\.exe|steamwebhelper'
+ ;;
+ *)
+ GAME_RE='D2R\.exe|BlizzardError\.exe'
+ UI_RE='Battle\.net\.exe.*--from-launcher|Battle\.net Launcher\.exe'
+ ;;
+esac
window_pids() {
/usr/bin/python3 - <<'PY'
@@ -53,6 +68,29 @@ PY
declare -A STRIKES
IDLE_STRIKES=0
+if [ "$MODE" = "steam" ]; then
+ # Wait for Steam to show a window first (login/update can take a while), then
+ # tear the bottle down once neither Steam nor a game has a window for 40s.
+ SEEN=0; NOWIN=0
+ while true; do
+ sleep "$INTERVAL"
+ PIDS=$(pgrep -f "$UI_RE|$GAME_RE" 2>/dev/null || true)
+ [ -z "$PIDS" ] && { [ "$SEEN" = 1 ] && exit 0; continue; }
+ WINS=" $(window_pids) "
+ HAS=0
+ for pid in $PIDS; do [[ "$WINS" == *" $pid "* ]] && { HAS=1; break; }; done
+ if [ "$HAS" = 1 ]; then SEEN=1; NOWIN=0; continue; fi
+ [ "$SEEN" = 1 ] || continue
+ NOWIN=$((NOWIN + 1))
+ if [ "$NOWIN" -ge 2 ]; then
+ WINEPREFIX="$PREFIX" "$WINESERVER" -k 2>/dev/null || true
+ sleep 3
+ pkill -9 -f "$UI_RE|steamservice\.exe" 2>/dev/null || true
+ exit 0
+ fi
+ done
+fi
+
while true; do
sleep "$INTERVAL"