Skip to content

Instantly share code, notes, and snippets.

@wannabegeek
Last active February 18, 2024 19:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save wannabegeek/f3452c0d4d7cf7710a49f6cc9e689ad3 to your computer and use it in GitHub Desktop.
Save wannabegeek/f3452c0d4d7cf7710a49f6cc9e689ad3 to your computer and use it in GitHub Desktop.
Running Zwift under wine on Linux
#!/bin/bash
# Setup should be fairly standard for wine
#
# Install wine version > 5.4
# Install winetricks
# > sudo dnf -y install win winetricks
#
# For the moment I have assumed the default WINEPREFIX
# > winetricks dotnet35sp1 win7
#
# Download the Windows version of Zwift and install (this will take quite some time)
#
# Download and install RunFromProcess from https://www.nirsoft.net/utils/run_from_process.html
# and place binaries in ${WINEPREFIX}/drive_c/Program Files (x86)/RunFromPRocess/ directory
# > mkdir "${WINEPREFIX:-${HOME}/.wine}/drive_c/Program Files (x86)/RunFromProcess/"
# > unzip -xv ~/Downloads/runfromprocess.zip -d "${WINEPREFIX:-${HOME}/.wine}/drive_c/Program Files (x86)/RunFromProcess"
#
# note: if Zwift requires updating you may need to run something like the following
# > cd "${ZWIFT_HOME}"
# > wine ZwiftLauncher.exe
# and wait for it to complete before running this script
WINEPREFIX=${WINEPREFIX:-${HOME}/.wine}
ZWIFT_HOME="${WINEPREFIX}/drive_c/Program Files (x86)/Zwift"
RUNFROMPROCESS_HOME="${WINEPREFIX}/drive_c/Program Files (x86)/RunFromProcess/"
# This is required fro Intel Integrated Graphics
export MESA_GL_VERSION_OVERRIDE=3.1
export WINEDEBUG=warn-all
# turn off sleeping while Zwift is running & cache the existing values for reverting later.
AC_SLEEP=$(gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type)
BATTERY_SLEEP=$(gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type)
IDLE_DELAY=$(gsettings get org.gnome.desktop.session idle-delay)
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type nothing
gsettings set org.gnome.desktop.session idle-delay 'uint32 0'
# Start the lancher
cd "${ZWIFT_HOME}"
wine ZwiftLauncher.exe > /dev/null &
LAUNCHER_PID=$! # This isn't used
# Give it sometime to start
sleep 10 # this may require adjusting depending on the erformance of the host machine
# Start the main process
wine "${RUNFROMPROCESS_HOME}/RunFromProcess.exe" ZwiftLauncher.exe ZwiftApp.exe
# This will just monitor for the main Zwift prcess to exit & then kill the launcher
while true
do
if [[ -z "$(ps auxww | grep ZwiftApp.exe | grep -v grep | awk '{print $2}')" ]];
then
echo "ZwiftApp has exited, shutting down launcher"
break
else
sleep 5
fi
done
# This will kill all windows processes under the current WINEPREFIX
wineserver -k
# Turn sleeping back on (or back to how it was before we started)
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type "${AC_SLEEP}"
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type "${BATTERY_SLEEP}"
gsettings set org.gnome.desktop.session idle-delay "${IDLE_DELAY}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment