Skip to content

Instantly share code, notes, and snippets.

@mcxiaoke
Created July 1, 2022 09:59
Show Gist options
  • Select an option

  • Save mcxiaoke/ea155ad1b39130b1517bf9ed07db2d69 to your computer and use it in GitHub Desktop.

Select an option

Save mcxiaoke/ea155ad1b39130b1517bf9ed07db2d69 to your computer and use it in GitHub Desktop.
A script intended to make Genshin Impact run perfectly on Linux using Wine + DXVK. You need to have a Wine installation, Winetricks is automatically installed in this script.
#!/bin/bash
VERSION="151"
PATCHES_DIR="$PWD/patches/$VERSION"
GAME_DIR="$PWD/files/drive_c/Program Files/Genshin Impact/Genshin Impact game"
if ! [ -d "$PWD/patches" ]; then
export WINEPREFIX="$PWD/files"
git clone https://notabug.org/Krock/GI-on-Linux.git patches
DIR="$PWD/patches"
(cd "$DIR" && git clone wget https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz)
(cd "$DIR" && tar -xzvf dxvk-async-1.8.1.tar.gz)
chmod +x "$DIR"/dxvk-async-1.8.1/setup_dxvk.sh
fi
"$DIR"/dxvk-async-1.8.1/setup_dxvk.sh install
(cd "$GAME_DIR" && bash "$PATCHES_DIR"/patch.sh)
(cd "$GAME_DIR" && bash "$PATCHES_DIR"/patch_anti_logincrash.sh)
#!/bin/bash
# Ensuring winetricks is installed.
if ! type -t "winetricks" &> /dev/null; then
read -p "Winetricks is not installed. We've a winetricks installer built-in. You want to proceed with the installation? ([y]es or [N]o): "
case $(echo $REPLY | tr '[A-Z]' '[a-z]') in
y|yes) install_wine_tricks ;;
*) exit 0 ;;
esac
fi
# Ensuring Wine is installed.
if ! type -t "wine" &> /dev/null; then
echo "Wine is not installed. We highly recommend installing the staging build."
exit 0
fi
# Install winetricks in any distro.
function install_wine_tricks() {
# Checking if the distro is Debian-based
if [ -f "/etc/debian_version" ]; then
echo "We have detected that the distribution in use is based on Debian. Proceeding with the winetricks installation..."
sudo apt-get install winetricks
else
# Checking for other distros
DISTRO_INFO="$(cut -d "=" -f2- <<< "$(cat /etc/*-release | grep DISTRIB_ID)")"
case $(echo $DISTRO_INFO | tr '[A-Z]' '[a-z]') in
arch|manjaro)
echo "We have detected that the distribution in use is based on Arch Linux. Proceeding with the winetricks installation..."
sudo pacman -Syy winetricks ;;
*)
echo "There is not built-in support for $DISTRO_INFO. Proceeding with standard installation."
echo "This may be a little bit harder way to update their packages in the future."
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo mv winetricks /usr/bin/
esac
fi
}
if ! [ -e "./_installer.exe" ]; then
wget -O _installer.exe "https://ys-api-os.mihoyo.com/event/download_porter/link/ys_global/genshinimpactpc/default"
fi
. ./common
# Create Wine prefix and execute installer.
if ! [ -d "$WINEPREFIX" ]; then
# Setup required dependencies.
winetricks --unattended vcrun2019 arial
"$WINE_BIN" "$PWD/_installer.exe"
fi
"${WINE_BIN}server" -k
LAUNCHER_PATH="$WINEPREFIX/drive_c/Program Files/Genshin Impact/launcher.exe"
"$WINE_BIN" "$LAUNCHER_PATH"

A script intended to make Genshin Impact run perfectly on Linux using Wine + DXVK. You need to have a Wine installation, Winetricks is automatically installed in this script.

Run order

genshin_launcher.bash then install the game. After the game installation you need to apply the patches using the apply_patches.bash script. Now you can run the game using launch_game.bash.

#!/bin/bash
export WINEPREFIX="$PWD/files"
export DXVK_ASYNC=1
export DXVK_HUD=fps
export DXVK_STATE_CACHE_PATH="$PWD/cache"
mkdir -p "$PWD"/cache
GAME_DIR="$PWD/files/drive_c/Program Files/Genshin Impact/Genshin Impact game"
gamemoderun wine "$GAME_DIR/GenshinImpact.exe"
@georgiapisoni
Copy link

could this be adapted to work on MacOS?

@vargamartonaron
Copy link

this seems outdated now

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