Skip to content

Instantly share code, notes, and snippets.

@mcoffin
Created November 6, 2017 21:56
Show Gist options
  • Select an option

  • Save mcoffin/8f3d4bca06df6442b4ac6a8bea9d2a19 to your computer and use it in GitHub Desktop.

Select an option

Save mcoffin/8f3d4bca06df6442b4ac6a8bea9d2a19 to your computer and use it in GitHub Desktop.
Wrapper script for League of Legends client in wine
#!/bin/bash
set -e
league_dir=$(dirname $0)
export MESA_GL_VERSION_OVERRIDE=4.5COMPAT
export VBLANK_MODE=0
export MESA_GLTHREAD=true
resolution=$(xrandr | grep ' connected ' | awk '{print $4}' | egrep -o '^[0-9]+x[0-9]+')
width=$(echo $resolution | awk -F 'x' '{print $1}')
height=$(echo $resolution | awk -F 'x' '{print $2}')
# Replaces a variable in the config file with a new value
replace_var() {
awk -F '=' "{ if (\$1 == \"$1\") { print \$1 \"=\" \"$2\\r\" } else { print \$0 } }"
}
# Now, update the game config file for our screen resolution
pushd "$league_dir/Config"
if [ -e 'game.cfg.bak' ]; then
if [ ! -z "$(diff game.cfg.bak game.cfg)"]; then
echo 'game.cfg.bak exists and there are differences with game.cfg. Refusing to continue.' >&2
echo 'If the game ran ok last time, it should be ok to delete it and continue' >&2
exit 1
fi
fi
cp game.cfg game.cfg.bak
cat 'game.cfg.bak' |
replace_var 'Height' "$height" |
replace_var 'Width' "$width" |
replace_var 'ItemShopPrevResizeWidth' "$width" |
replace_var 'ItemShopPrevResizeHeight' "$height" > game.cfg
popd
# Finally, run the game
wine "$league_dir/LeagueClient.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment