Skip to content

Instantly share code, notes, and snippets.

@Raniz85
Last active December 23, 2024 10:35
Show Gist options
  • Save Raniz85/6c431fa114c855161b97eb764514c6e0 to your computer and use it in GitHub Desktop.
Save Raniz85/6c431fa114c855161b97eb764514c6e0 to your computer and use it in GitHub Desktop.
Script for launching Zwift installed with Lutris. Put your password in ~/.zwiftpassword and it will be placed in the clipboard once the game has been started
#!/bin/bash
cd ~/Games/zwift
# Where you installed Zwift
zwiftLocation="$HOME/Games/zwift"
# The ID in Lutris of Zwift
lutrisGameId=1
startLauncher() {
# If the script doesn't work, run the game as usual and dump the ENV from the ZwiftLauncher.exe wrapper with:
# cat /proc/<pid of lutris-wrapper>/environ | tr "\0" "\n"
# and copy the values from there
export WINEARCH="win64"
export WINE="$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/bin/wine"
export WINEPREFIX="$zwiftLocation"
export
LD_LIBRARY_PATH="$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/lib:$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/lib64:/usr/lib:/usr/lib32:/usr/lib/openmpi:/usr/lib/libfakeroot:/usr/lib64:$HOME/.local/share/lutris/runtime/Ubuntu-18.04-i686:$HOME/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:$HOME/.local/share/lutris/runtime/steam/i386/lib:$HOME/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:$HOME/.local/share/lutris/runtime/steam/i386/usr/lib:$HOME/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:$HOME/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:$HOME/.local/share/lutris/runtime/steam/amd64/lib:$HOME/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:$HOME/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
export SDL_VIDEO_FULLSCREEN_DISPLAY="off"
export DRI_PRIME="1"
export WINEDEBUG="-all"
export GST_PLUGIN_SYSTEM_PATH_1_0="$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/lib64/gstreamer-1.0/:$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/lib/gstreamer-1.0/"
export WINEESYNC="1"
export WINEFSYNC="0"
export DXVK_NVAPIHACK="0"
export WINEDLLOVERRIDES="d3d10core,d3d11,d3d12,d3d9,d3dcompiler_42,d3dcompiler_43,d3dcompiler_46,d3dcompiler_47,d3dx10,d3dx10_33,d3dx10_34,d3dx10_35,d3dx10_36,d3dx10_37,d3dx10_38,d3dx10_39,d3dx10_40,d3dx10_41,d3dx10_42,d3dx10_43,d3dx11_42,d3dx11_43,d3dx9_24,d3dx9_25,d3dx9_26,d3dx9_27,d3dx9_28,d3dx9_29,d3dx9_30,d3dx9_31,d3dx9_32,d3dx9_33,d3dx9_34,d3dx9_35,d3dx9_36,d3dx9_37,d3dx9_38,d3dx9_39,d3dx9_40,d3dx9_41,d3dx9_42,d3dx9_43,dxgi,nvapi,nvapi64,nvml=n;winemenubuilder="
export PYTHONPATH="/usr/lib/lutris:/usr/bin:/usr/lib/python310.zip:/usr/lib/python3.10:/usr/lib/python3.10/lib-dynload:/usr/lib/python3.10/site-packages"
python3 \
/usr/share/lutris/bin/lutris-wrapper \
"$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/bin/wine" \
0 \
0 \
"$HOME/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/bin/wine" \
"$zwiftLocation/drive_c/Program Files (x86)/Zwift/ZwiftLauncher.exe" &
launcherPid="$!"
}
startLauncher
echo "Zwift launcher started with PID $launcherPid"
gamePid=""
trap "exitCleanly" SIGINT
trap "exitCleanly" EXIT
exitCleanly() {
if [[ "$launcherPid" != "" ]];
then
echo "Killing $launcherPid"
kill $launcherPid
launcherPid=""
fi
if [[ "$gamePid" != "" ]];
then
echo "Killing $gamePid"
kill $gamePid
gamePid=""
fi
exit 0
}
while ! xdotool search --classname zwiftlauncher.exe;
do
sleep 0.5s
done
sleep 10s
echo "Launcher started; starting game"
env LUTRIS_SKIP_INIT=1 lutris lutris:rungameid/$lutrisGameId &
lutrisPid=$!
echo "Lutris started with PID $lutrisPid"
wait $lutrisPid
gamePid=$(pidof ZwiftApp.exe)
echo "Game started with PID $gamePid"
if [ -f ~/.zwiftpassword ];
then
echo "Placing password into clipboard"
cat ~/.zwiftpassword | xclip
fi
while [ -d /proc/$gamePid ]; do sleep 1; done
echo "Game exited; killing launcher"
gamePid=""
exitCleanly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment