Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

hl2-optimus.sh - 12/12/12-B

By: a guest on Dec 12th, 2012  |  syntax: Bash  |  size: 2.83 KB  |  views: 775  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. # hl2-optimus.sh
  3. # hl2.sh modified for Source games and optirun/primusrun
  4. # http://steamcommunity.com/groups/LinuxOptimus
  5. #
  6. # EXPERIMENTAL!
  7. # Version: 12/12/12-B
  8.  
  9. # Valve's stuff goes here
  10. GAMEROOT=$(cd "${0%/*}" && echo $PWD)
  11. STEAMPATH=$(readlink ~/.steampath)
  12. export LD_LIBRARY_PATH="${GAMEROOT}"/bin:$LD_LIBRARY_PATH
  13. if [ ! -z ${STEAMPATH} ]; then
  14.   export LD_LIBRARY_PATH="$(dirname ${STEAMPATH})":$LD_LIBRARY_PATH
  15. fi
  16. ulimit -n 2048
  17. export __GL_THREADED_OPTIMIZATIONS=1
  18. cd "$GAMEROOT"
  19.  
  20. # Our library path
  21. export LD_LIBRARY_PATH=$(cd ../../.. && echo $PWD)/ubuntu12_32:$LD_LIBRARY_PATH
  22.  
  23. # Guess game and id
  24. if [ -d tf_beta ]; then
  25.   gameid=520
  26.   game="-game tf_beta"
  27. elif [ -d tf ]; then
  28.   gameid=440
  29.   game="-game tf"
  30. elif [ -d hl2mp ]; then
  31.   gameid=320
  32.   game="-game hl2mp"
  33. elif [ -d lostcoast ]; then
  34.   gameid=340
  35.   game="-game lostcoast"
  36. elif [ -d episodic ]; then
  37.   gameid=380
  38.   game="-game episodic"
  39. elif [ -d ep2 ]; then
  40.   gameid=420
  41.   game="-game ep2"
  42. elif [ -d hl1 ]; then
  43.   gameid=280
  44.   game="-game hl1"
  45. elif [ -d portal ]; then
  46.   gameid=400
  47.   game="-game portal"
  48. elif [ -d portal2 ]; then
  49.   gameid=620
  50.   game="-game portal2"
  51. elif [ -d left4dead ]; then
  52.   gameid=500
  53.   game="-game left4dead"
  54. elif [ -d left4dead2 ]; then
  55.   gameid=550
  56.   game="-game left4dead2"
  57. elif [ -d cstrike_beta ]; then
  58.   gameid=260
  59.   game="-game cstrike_beta"
  60. elif [ -d cstrike ]; then
  61.   gameid=240
  62.   game="-game cstrike"
  63. elif [ -d dodsbeta ]; then
  64.   gameid=302
  65.   game="-game dodsbeta"
  66. elif [ -d dod ]; then
  67.   gameid=300
  68.   game="-game dod"
  69. elif [ -d garrysmod ]; then
  70.   gameid=4000
  71.   game="-game garrysmod"
  72. elif [ -d garrysmodbeta ]; then
  73.   gameid=4010
  74.   game="-game garrysmodbeta"
  75. elif [ -d hl2 ]; then
  76.   echo "Warning: Only hl2 game folder detected. Guessing you want hl2."
  77.   gameid=220
  78.   game=""
  79. else
  80.   echo "Could not find a valid game."
  81.   exit
  82. fi
  83.  
  84. # Allow user to decide vblank_mode
  85. # Disabled by default due to input lag for some people
  86. if [ -z $vblank_mode ]; then
  87.   vblank_mode=0
  88. fi
  89.  
  90. # Check if user has force disabled primus
  91. if [ -z $use_primus ]; then
  92.   use_primus=1
  93. fi
  94.  
  95. # Make sure primus is installed
  96. if [ $use_primus -eq 1 ]; then
  97.   if command -v primusrun &>/dev/null; then
  98.     echo "Primus has been detected and will be used. Launch with 'use_primus=0 $0' to disable."
  99.     echo "Try disabling if you experience stuttering, graphical/font glitches, or other issues."
  100.     use_primus=1
  101.   else
  102.     use_primus=0
  103.   fi
  104. fi
  105.  
  106. # Place guessed id to steam_appid.txt
  107. # Needed when launching away from Steam
  108. echo $gameid>steam_appid.txt
  109.  
  110. # Launch!
  111. if [ $use_primus -eq 1 ]; then
  112.   vblank_mode=$vblank_mode primusrun ./hl2_linux $game -steam -novid "$@"
  113. else
  114.   optirun ./hl2_linux $game -steam -novid "$@"
  115. fi
  116.  
  117. # Remote steam_appid.txt in case it was guessed wrong
  118. rm steam_appid.txt