Skip to content

Instantly share code, notes, and snippets.

@sigzegv
Last active June 9, 2023 18:16
Show Gist options
  • Save sigzegv/b5f2d57121c15aef7841ba9373221cab to your computer and use it in GitHub Desktop.
Save sigzegv/b5f2d57121c15aef7841ba9373221cab to your computer and use it in GitHub Desktop.
wine cli scripts
#!/bin/bash
# Source this script to set a given wineprefix as current prefix,
# and winerunner as default wine command is the current terminal.
# You will be able to just use 'wine' command in the terminal and make action to prefix.
#
# Wine runner path must be the path containing the bin/wine directory.
# if /some/wine/path/bin/wine then use /some/wine/path (this also applies to Proton runners)
#
# ie: $ source winesource /to/some/prefix /with/some/winerunner
#
# It's also able to auto able to autodetect a steam prefix,
# just pass the steam game ID as prefix
# ie: $ source winesource 014314T54 /with/some/winerunner
steampath="$HOME/.steam/steam/steamapps/compatdata"
winepfx=$1
[ -z "$winepfx" ] && { echo "missing first parameter path for wineprefix"; return 1; }
[ -d "$steampath/$1/pfx" ] && {
echo -e "found \e[33m$steampath/$1/pfx\e[0m wineprefix."
winepfx="$steampath/$1/pfx"
}
[ -d "$winepfx" ] || { echo "$winepfx path does not exists"; return 1; }
[ -d "$winepfx/drive_c" ] || { echo -e "\e[33m$winepfx\e[0m is not a wineprefix"; return 1; }
[ -z "$2" ] && { echo "missing second parameter path for wine runner"; return 1; }
[ -d "$2" ] || { echo "$2 path does not exists"; return 1; }
[ -x "$2/bin/wine" ] || { echo -e "\e[33m$2\e[0m is not a wine runner"; return 1; }
export WINEPREFIX="$winepfx"
export PATH="$PATH:$2/bin"
export LD_LIBRARY_PATH="$2/lib:$LD_LIBRARY_PATH"
echo -e "Using \e[33m$winepfx\e[0m as WINEPREFIX"
echo -e "Using \e[33m$2\e[0m as wine runner"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment