Advertisement
Guest User

Wine prefix script

a guest
Nov 1st, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.55 KB | None | 0 0
  1. SOURCE FILE:--------------------------------------
  2.  
  3. #Fundamental: Can save you from some headaches on 64-bit systems, such as when the system's default Wine (which often is 64-bit) is used instead of the supplied 32-bit Wine.
  4. export WINEARCH=win32
  5. #General: Some general options that apply to all scripts and make sure that everything is alright.
  6. [[ -z $WINEDLLOVERRIDES ]] && export WINEDLLOVERRIDES="winemenubuilder.exe=d" #Prohibit creation of desktop entries while allowing custom setting in script
  7. [[ -z $WINEDEBUG ]] && export WINEDEBUG="-all" #Defaults to the most efficient option, allows setting in script
  8. [[ -z "$WINEPREFIX" ]] && printf "$(tput bold)$(tput setaf 1)Warning: \$WINEPREFIX is not defined; please define it.\n$(tput sgr0)" && exit 1 #Used in order to avoid starting in the default prefix
  9. [[ "$WINEPREFIX" = "$HOME/.local/share/wineprefixes/" ]] && printf "$(tput bold)$(tput setaf 1)Warning: Incomplete script. Please stop define \$WINEPREFIX properly.\n$(tput sgr0)" && exit 1
  10.  
  11. #Prefix specific settings
  12. #Useful if there are multiple games using the same prefix; they will use the same settings, and the scripts for each individual games are minimized in size.
  13. WINE_GLOBAL_WINEVER=1.7.2 #Default version; the script is built upon using custm Wine versions
  14.  
  15. [[ "$WINEPREFIX" = "$HOME/.local/share/wineprefixes/NFS" ]] && export WINEVER=$WINE_GLOBAL_WINEVER
  16.  
  17. #Steam has multiple default settings. These settings may also be overridden in a script, and some exceptions have been made in order to support a wider amount of games. Some games don't like GL threading, some games need a patched Wine and etc.
  18. WINE_APP_STEAM_WINEVER=1.7.2
  19. if [[ "$WINEPREFIX" = "$HOME/.local/share/wineprefixes/Steam" ]]; then
  20.     if [[ -z $STEAM_WINEVER_OVERRIDE ]]; then
  21.         export WINEVER=$WINE_APP_STEAM_WINEVER
  22.     else
  23.         export WINEVER=$STEAM_WINEVER_OVERRIDE
  24.     fi
  25.     if [[ -z $GLTHREAD ]] && [[ -z $GLTHREAD_OVERRIDE ]]; then
  26.         export GLTHREAD=1
  27.     fi
  28. fi
  29.  
  30. WINE_GAME_HALO_WINEVER=1.5.20
  31. [[ "$WINEPREFIX" = "$HOME/.local/share/wineprefixes/Halo" ]] && export WINEVER=$WINE_GAME_HALO_WINEVER
  32. [[ "$WINEPREFIX" = "$HOME/.local/share/wineprefixes/Halo1.00" ]] && export WINEVER=$WINE_GAME_HALO_WINEVER
  33. [[ "$WINEPREFIX" = "$HOME/.local/share/wineprefixes/HaloCE_OS" ]] && export WINEVER=$WINE_GAME_HALO_WINEVER
  34.  
  35. #If no WINEVER is set, the default version will be used.
  36. if [[ -z $WINEVER ]];then
  37.     printf "$(tput bold)$(tput setaf 4)Warning: No Wine version was provided. Will default to version $WINE_GLOBAL_WINEVER.\n$(tput sgr0)"
  38.     export WINEVER=$WINE_GLOBAL_WINEVER
  39. fi
  40.  
  41. #Imports the binaries of a custom build of Wine to the PATH variable. Commenting out these lines would make it use the default one.
  42. export WINEBIN=$HOME/Winebuilds/$WINEVER/bin/wine #A relic; unstable and not really practical.
  43. export PATH=$HOME/Winebuilds/${WINEVER}/bin:$PATH #Append the specific Wine version to PATH within script; does not work globally.
  44.  
  45. #Option handling: Simplify the setting of environment variables while keeping it simple. LOG_TIME is a function that kind of works for non-Steam games for counting hours and is added upon personal preference. The resulting files of LOG_TIME are easily understandable, as it appends the game session's time to a list of game times. From it one can calculate average playtime or total playtime. Some other options are for optimization or compatibility, as is the case with PA_DSPMODE.
  46. if [[ $GLTHREAD = 1 ]]; then
  47.     printf "$(tput bold)$(tput setaf 4)OpenGL threading is enabled\n$(tput sgr0)"
  48.     export LD_PRELOAD="libpthread.so.0 libGL.so.1"
  49.     export __GL_THREADED_OPTIMIZATIONS=1
  50. fi
  51. if [[ -n $GLAA ]]; then
  52.     printf "$(tput bold)$(tput setaf 4)Antialiasing forced to mode $GLAA\n$(tput sgr0)"
  53.     export __GL_FSAA_MODE=$GLAA
  54. fi
  55. if [[ -n $GLANISO ]]; then
  56.         printf "$(tput bold)$(tput setaf 4)Anisotropic filtering forced to mode $GLANISO\n$(tput sgr0)"
  57.         export __GL_LOG_MAX_ANISO=$GLANISO
  58. fi
  59. if [[ $GLVBLANK = 1 ]]; then
  60.         printf "$(tput bold)$(tput setaf 4)Sync to vblank enabled\n$(tput sgr0)"
  61.         export __GL_SYNC_TO_VBLANK=1
  62. else
  63.     printf "$(tput bold)$(tput setaf 4)Sync to vblank disabled\n$(tput sgr0)"
  64.         export __GL_SYNC_TO_VBLANK=0
  65. fi
  66. if [[ $LOG_TIME = 1 ]]; then
  67.     LOG_BASE_DIR="$HOME/System/Gametimes"
  68.     if [[ -n "$LOG_FILE_NAME" ]]; then
  69.     printf "$(tput bold)$(tput setaf 4)Info: Time logging enabled\n$(tput sgr0)"
  70.     WINE_RUN_PREFIX="/usr/bin/time --format=%e -a -o "${LOG_BASE_DIR}/${LOG_FILE_NAME}" $WINE_RUN_PREFIX"
  71.     else
  72.     printf "$(tput bold)$(tput setaf 3)Warning: No log file for time logging specified. Skipping.\n$(tput sgr0)"
  73.     fi
  74. fi
  75. if [[ $PA_DSPMODE = 1 ]];then
  76.     printf "$(tput bold)$(tput setaf 4)PulseAudio DSP mode enabled\n$(tput sgr0)"
  77.     WINE_RUN_PREFIX="$WINE_RUN_PREFIX padsp"
  78. fi
  79. export WINE_RUN_PREFIX
  80.  
  81. #Functions: Mini-scripts to be used in interactive shells or for simplicity.
  82. test_environment(){
  83. #Used for a quick overview of the current environment, mostly for debugging purposes.
  84. printf "$(tput bold)$(tput setaf 4)
  85. $(export)
  86. Debug parameters: $WINEDEBUG
  87. Prefix: $WINEPREFIX
  88. Wine binary: $WINEBIN
  89. $([[ $GLTHREAD = 1 ]] && printf "OpenGL Threading: $__GL_THREADED_OPTIMIZATIONS, $LD_PRELOAD")
  90. Current directory: $PWD
  91. Wine version: $WINEVER\n$(tput sgr0)"
  92. }
  93. explorer(){
  94. wine explorer
  95. }
  96. regedit(){
  97. wine regedit
  98. }
  99.  
  100. #Aliases: Wine-specific aliases; define them yourself.
  101. alias wine-4gb-fixer="wine $HOME/Game\ mods/4gb_patch.exe" #Solves a LOT of issues with memory bottlenecking because of 32-bit. Skyrim, Metro 2033 and others really need this tool to work as best as they can with high memory consumption.
  102.  
  103.  
  104.  
  105.  
  106.  
  107. -----------------------------------------------
  108.  
  109. Template file:------------------------------------
  110.  
  111. #! /bin/bash
  112. #Environment variables
  113. export WINEPREFIX=$HOME/.local/share/wineprefixes/ #Needs to be complete with prefix; not changing this will make the script stop as a safety measure.
  114. GLTHREAD=0
  115. #GLAA=
  116. #GLANISO=
  117. WINEVER=
  118. source "$HOME/Quicklists/Wine launchers/wine_globalrc.sh" #Source script that uses provided information to set up the environment.
  119.  
  120. #Pre-run: Most likely cd'ing into the directory of the executable.
  121. cd "$WINEPREFIX/drive_c/"
  122.  
  123. #Running: Perhaps the most hacky solution I've made for the script. It tests if there are more than 2 bytes of input, and will run the command if this is true. Needs improvement.
  124. if [ "$(echo $@|wc -c)" -ge 2 ];then
  125. "$@"
  126. else
  127. $WINE_RUN_PREFIX wine
  128. fi
  129. #WINE_RUN_PREFIX is defined by the source script and involves things such as PA_DSP
  130.  
  131. #Template for running with a virtual desktop
  132. #$WINE_RUN_PREFIX wine explorer /desktop=TITLE,1920x1080
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement