Skip to content

Instantly share code, notes, and snippets.

@Ryochan7
Last active March 6, 2016 19:35
Show Gist options
  • Save Ryochan7/d5cd8256964237063e00 to your computer and use it in GitHub Desktop.
Save Ryochan7/d5cd8256964237063e00 to your computer and use it in GitHub Desktop.
Base template for launching Windows games in SteamOS using Wine
#!/bin/sh
## This script is used to launch Windows games by using
## the Windows Steam client in a Wine virtual desktop.
## Credit goes to iVaN, dubigrasu, and Ryochan7 for creating various portions
## of this script. Discussion of this technique is currently being done at
## https://steamcommunity.com/groups/steamuniverse/discussions/1/494632768626127072/.
##########################################
# #
# User configurable variables for use in #
# this script #
# #
##########################################
# Define some Wine variables for use in the script.
export WINEPREFIX="/home/steam/.PlayOnLinux/wineprefix/Steam"
export WINEDEBUG="-all"
WINEVERSION="$HOME/.PlayOnLinux/wine/linux-x86/1.8"
export LD_LIBRARY_PATH="$WINEVERSION/lib:$WINEVERSION/lib64:$LD_LIBRARY_PATH"
export PATH="$WINEVERSION/bin:$PATH"
# Define Steam location and game location here.
# NOTE: GAME_DIR is not used with current method. Possibly remove?
STEAM_DIR="$WINEPREFIX/drive_c/Program Files/Steam"
GAME_APPID="204340"
GAME_DIR="steamapps/common/Serious Sam 2/Bin"
GAME_EXE="Sam2.exe"
###########################################
# #
# MAIN SCRIPT. DO NOT EDIT UNLESS #
# ABSOLUTELY NECESSARY #
# #
###########################################
# Obtain the resolution of the current display so the Wine virtual
# desktop will be full-screen.
RES=$(xdpyinfo | grep "dimensions" | awk '{print $2}')
VIRT_DESK="explorer /desktop=Steam,$RES"
# Change to Steam directory and launch Wine virtual desktop.
cd "$STEAM_DIR"
$WINEVERSION/bin/wine $VIRT_DESK &
# Allow a little sleep time so steamcompmgr uses the virtual desktop
# window.
sleep 3
# Don't use extra libraries for other applications running in Wine.
# The virtual desktop will be used by steamcompmgr.
export LD_PRELOAD=
# Launch game from Steam. The game appid used by Steam can be found from the
# Steam store page for a game or from https://steamdb.info/.
env -i DISPLAY=$DISPLAY WINEPREFIX=$WINEPREFIX WINEDEBUG=$WINEDEBUG LD_LIBRARY_PATH=$LD_LIBRARY_PATH PATH=$PATH "$WINEVERSION/bin/wine" $VIRT_DESK "$STEAM_DIR/Steam.exe" -applaunch "$GAME_APPID" &
# Wait for application to be launched.
until [ -n "$(ps ax -o comm= | grep -i "$GAME_EXE")" ]; do
sleep 2
done;
# Stay in loop while the game is running.
while [ -n "$(ps ax -o comm= | grep -i "$GAME_EXE")" ]; do
sleep 2
done;
# Shut down the Windows Steam client.
if [ -n "$(pgrep -lf Steam\.exe)" ]; then
"$WINEVERSION/bin/wine" $VIRT_DESK "$STEAM_DIR/Steam.exe" -shutdown
# Wait for Steam client to close completely.
while pgrep -lf "Steam\.exe"; do
sleep 2
done;
fi;
# Kill Wine server so Steam will properly return to the library interface.
"$WINEVERSION/bin/wineserver" -k
@thehack
Copy link

thehack commented Feb 8, 2016

Hi @Ryochan7 . Thanks for making this launcher. After a bit of fiddling I've managed to use it to launch and play Rocket League on SteamOS.

First I see the wine virtual desktop launch, a few seconds later the game itself launches. However, it's inconsistent. Approximately one-half of my attempts end in the game being launched behind the dark blue steam animated loading screen. I can hear the game but not see it and I have to restart because the mouse and controller are grabbed by the game.

I'm wondering if you have any insight to this behavior. Would increasing or decreasing the sleep time on line 49 or 61 make it work more reliably?

@formicsapien
Copy link

I have the exact same problem as @thehack. Again, thanks for the work, ryochan@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment