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.

steam: let the wineserver flush before editing user.reg, boot the prefix in the clean env

mikey924c5896e0b840
diff --git a/scripts/play.sh b/scripts/play.sh
index 961af27508e..c86ae2315c9 100755
--- a/scripts/play.sh
+++ b/scripts/play.sh
@@ -191,12 +191,26 @@ case "$MODE" in
cp -f "$WRAP" "$d/steamwebhelper.exe"
fi
done
- # 3) Drop Steam's autostart entry. Steam adds itself to the prefix's Run key
+ # 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}")
+ # 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.
- "$WINESTABLE" reg delete 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' \
+ "${STEAM_ENV[@]}" "$WINESTABLE" reg delete 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' \
/v Steam /f >/dev/null 2>&1 || true
- # 4) Virtual desktop: this macdrv (gcenx wine 11) ignores virtual desktops,
+ # 5) 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).
@@ -209,11 +223,7 @@ case "$MODE" in
VD="1728x1080"
fi
fi
- # Keep virtual-desktop windows movable (one-time registry setting)
- grep -q 'AllowImmovableWindows' "$WINEPREFIX/user.reg" 2>/dev/null || {
- printf '\n[Software\\\\Wine\\\\Mac Driver]\n"AllowImmovableWindows"="n"\n' >> "$WINEPREFIX/user.reg"
- }
- # 5) Launch: plain wine-stable environment, without the CX engine env
+ # 6) 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[@]}")
# Closing the Steam window parks it in a tray macOS does not show; the patched
@@ -224,9 +234,7 @@ case "$MODE" in
# 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 & ); }
- 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}" \
+ "${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" \
diff --git a/scripts/setup-steam-games.sh b/scripts/setup-steam-games.sh
index 6e8843cfe3a..2569bf72b2b 100755
--- a/scripts/setup-steam-games.sh
+++ b/scripts/setup-steam-games.sh
@@ -69,6 +69,9 @@ for APP in steam.exe steamwebhelper.exe steamwebhelper_real.exe steamservice.exe
done
echo "==> 5/5 Removing the fullscreen-forcing AppCompat token (allows windowed mode)"
+# The reg adds above left a wineserver up with a dirty HKCU; it rewrites
+# user.reg when it exits, which would undo an edit made now. Wait for it.
+"$WAPP/bin/wineserver" -w 2>/dev/null || true
/usr/bin/python3 - "$WINEPREFIX/user.reg" <<'EOF'
import sys
p = sys.argv[1]