Skip to content

Instantly share code, notes, and snippets.

@shmerl
Last active June 11, 2025 01:34
Show Gist options
  • Save shmerl/edf230db5d4a24fd92aea16c31393d89 to your computer and use it in GitHub Desktop.
Save shmerl/edf230db5d4a24fd92aea16c31393d89 to your computer and use it in GitHub Desktop.
Custom Wine running
#!/bin/bash
# Configuration (set through environment variables):
#
# WINEPREFIX - what prefix to use.
# wine_path - to use custom location of Wine (e.g. /opt/wine-main).
# wine - shortcut for the above, to assume /opt/$wine
# wine_cleanup - run some command after wine exits
#
# Notes:
#
# WINEPREFIX this one you most probably need, otherwise, it will fall back to
# default prefix at $HOME/.wine
#
# wine_path should be set if you need custom Wine, otherwise it will fall back to
# default (implicit) Wine, which is a common usage. This is not a Wine env variable,
# but a custom variable used in the script to set a location if needed.
#
# wine can be set without wine_path, to use /opt/$wine location.
#
# Uses wine_env.sh which sets the environment
#
function cleanup() {
$wine_cleanup
}
source $(dirname $(realpath --no-symlinks ${BASH_SOURCE[0]}))/wine_env.sh
if [[ "${wine_cleanup+iset}" ]]; then
trap cleanup EXIT
fi
echo "Wine environment"
printf "Wine prefix : "
if [[ "${WINEPREFIX+iset}" ]]; then
echo "$WINEPREFIX"
else
echo "default(!)"
fi
printf "Wine location: "
if [[ "${wine_path+iset}" ]]; then
echo "$wine_path"
else
echo "default"
fi
echo "Wine command : $(command -v wine)"
echo "==========================================="
if [[ "${wine_cleanup+iset}" ]]; then
# exec doesn't work with trap, so we have to keep the shell around for this case
wine "$@"
else
exec wine "$@"
fi
@shmerl
Copy link
Author

shmerl commented Feb 26, 2025

Updated to use latest Wine which got rid of wine64 binary.

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