Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## wine wrapper, install on your path somewhere
- #!/usr/bin/env bash
- WINE_DDRAW_OVERRIDE=WINEDLLOVERRIDES="ddraw=n"
- NVIDIA_PRIME_GLX=__NV_PRIME_RENDER_OFFLOAD=1\ __GLX_VENDOR_LIBRARY_NAME=nvidia
- config=${CONFIG:-~/.config/wine-wrapper.conf}
- function name() {
- echo ${0##*/}
- }
- function wine() {
- local wine=($(which -a "$(name)"))
- wine=(${wine[@]/$(realpath -s "$0")})
- echo $wine;
- }
- function usage() {
- cat << EOF >&2
- usage: $(name) [-c|--config <file>] [-d|--debug] [--print] [--glx] [--ddraw] [--clean] PROGRAM [ARGUMENTS]
- --help display this help and exit
- --help-wine execute $(wine) --help
- -c,--config <file> use <file> instead of ${config}
- --print print complete environment and exit
- -d,--debug echo commands to console
- --glx set ${NVIDIA_PRIME_GLX}
- --ddraw set ${WINE_DDRAW_OVERRIDE}
- --clean unset environment
- EOF
- exit
- }
- TEMP=$(getopt -n "$(name)" -o "?hdc:" -l "help,help-wine,debug,print,glx,ddraw,clean,config:" -- "$@")
- [[ $? -ne 0 ]] && usage
- eval set -- "$TEMP"
- unset TEMP
- auto=true
- clean=false
- debug=
- print=false
- while true
- do
- case "$1" in
- -\?|-h|--help)
- usage
- ;;
- --help-wine)
- exec $(wine) --help
- ;;
- -c|--config)
- config=$2
- shift 2
- ;;
- -d|--debug)
- debug=echo
- shift
- ;;
- --print)
- print=true
- shift
- ;;
- --glx)
- env+=(${NVIDIA_PRIME_GLX})
- auto=false
- shift
- ;;
- --ddraw)
- env+=(${WINE_DDRAW_OVERRIDE})
- auto=false
- shift
- ;;
- --clean)
- clean=true
- auto=false
- shift
- ;;
- --)
- shift
- break
- ;;
- *)
- usage
- ;;
- esac
- done
- declare -A environment
- [[ -r ${config} ]] && . ${config}
- $print && {
- for key in "${!environment[@]}"
- do
- printf "%s: %s\n" "${key}" "${environment[$key]}"
- done
- exit
- }
- [[ $# -eq 0 ]] && usage
- $clean && unset env
- shopt -s nocasematch
- $auto && for arg
- do
- case "${arg,,}" in
- *.lnk|*.exe)
- path=$(realpath -qe "$arg")
- ;;
- *)
- continue
- ;;
- esac
- for key in "${!environment[@]}"
- do
- [[ $arg =~ $key ]] || [[ $path =~ $key ]] && env=${environment[$key]}
- done
- unset path
- done
- ## FIXME: since debug here is a simple echo, argument quoting is swallowed
- if [ -v env ]; then
- $debug env ${env[@]} $(wine) "$@"
- else
- $debug $(wine) "$@"
- fi
- $debug xrandr -s 0
- ## Example configuration file
- #!/usr/bin/env bash
- declare -A environment=(
- [Stardock/Impulse.lnk]=
- [Stardock/Open Impulse Dock.lnk]=
- [Galactic Civilizations II - Ultimate Edition/Galactic Civilizations II - Ultimate Edition.lnk]=
- [Doom 3/Documentation.lnk]=
- [Doom 3/1.3 Patch Readme.lnk]=
- [Doom 3/Doom 3.lnk]=${NVIDIA_PRIME_GLX}
- [Doom 3/Uninstall Doom 3.lnk]=
- [Tiberian Sun/Tiberian Sun Game.lnk]=${WINE_DDRAW_OVERRIDE}
- [Tiberian Sun/Tiberian Sun Launcher.lnk]=${WINE_DDRAW_OVERRIDE}
- [Tiberian Sun/Uninstall Command & Conquer Tiberian Sun.lnk]=
- [Total War - Rome II/Uninstall.lnk]=
- [Total War - Rome II/Total War - Rome II.lnk]=${NVIDIA_PRIME_GLX}
- [Command & Conquer 95/Command & Conquer Gold Configuration.lnk]=
- [Command & Conquer 95/Uninstall C&C95.lnk]=
- [Command & Conquer 95/Command & Conquer Windows 95 Edition.lnk]=${WINE_DDRAW_OVERRIDE}
- [DOOM 3 Resurrection of Evil/Documentation.lnk]=
- [DOOM 3 Resurrection of Evil/Uninstall DOOM 3 Resurrection of Evil.lnk]=
- [DOOM 3 Resurrection of Evil/DOOM 3 Resurrection of Evil.lnk]=${NVIDIA_PRIME_GLX}
- [Red Alert/Red Alert.lnk]=${WINE_DDRAW_OVERRIDE}
- [Full Control Studios/Space Hulk/Space Hulk.lnk]=${NVIDIA_PRIME_GLX}
- [Full Control Studios/Space Hulk/Uninstall Space Hulk.lnk]=
- [Space Hulk - Ascension/Space Hulk - Ascension.lnk]=${NVIDIA_PRIME_GLX}
- [Space Hulk - Ascension/Uninstall Space Hulk - Ascension.lnk]=
- [Space Hulk - Deathwing EE/Space Hulk - Deathwing EE.lnk]=${NVIDIA_PRIME_GLX}
- [Space Hulk - Deathwing EE/Uninstall Space Hulk - Deathwing EE.lnk]=
- [GalCiv2.exe]=
- [Rome2.exe]=${NVIDIA_PRIME_GLX}
- [DOOM3.exe]=${NVIDIA_PRIME_GLX}
- [C&C95.exe]=${WINE_DDRAW_OVERRIDE}
- [ra95.exe]=${WINE_DDRAW_OVERRIDE}
- [Tiberian Sun/Game.exe]=${WINE_DDRAW_OVERRIDE}
- [Tiberian Sun/Launcher.exe]=${WINE_DDRAW_OVERRIDE}
- )
Advertisement
Add Comment
Please, Sign In to add comment