SHARE
TWEET

monitor-BFBC2-binds.sh

betlog Oct 10th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # betlog 2019-10-09
  3. evrouterFile="/home/user/.steamdata/BFBC2.evrouterrc"
  4. xbindkeysFile="/home/user/.steamdata/BFBC2.xbindkeysrc"
  5.  
  6. f_closeSelf() {
  7.     xdotool getwindowfocus key alt+F4
  8. }
  9. trap f_closeSelf EXIT
  10. echo $0
  11.  
  12. # AHK
  13. if [[ 0 -eq $(ps -C autokey-gtk -o pid=|sed 's/\ //') ]]; then
  14.     setsid autokey-gtk &> /dev/null
  15. fi
  16. if [[ $(ps -C autokey-gtk -o pid=|sed 's/\ //') ]]; then
  17.     echo "$(date +%Y-%m-%d--%H-%M-%S) - AUTOKEY active"    
  18. fi
  19.  
  20. # MAKE SURE EVROUTER IS STARTED
  21. evrouter -q &> /dev/null
  22. sleep 1s
  23. rm -f /tmp/.evrouter* &> /dev/null
  24. setsid evrouter -c "$evrouterFile" $(evrouter /dev/input/event* 2> /dev/null |grep Logitech|sed -E 's/^.*( \/.*)/\1/;s/ //;s/:.*//') 1> /dev/null
  25. # evrouter -c "$evrouterFile" $(evrouter /dev/input/event* 2> /dev/null |grep Logitech|sed -E 's/^.*( \/.*)/\1/;s/ //;s/:.*//')
  26. # if [[ -n $(ps -C evrouter -o pid=) ]]; then
  27. if [[ -n $(ps -C evrouter -o pid=|sed 's/\ //') ]]; then
  28.     echo "$(date +%Y-%m-%d--%H-%M-%S) - EVROUTER active"
  29. fi    
  30.  
  31. # START BFBC2
  32. bfbc2=$(ps -C steam -o args=)
  33. if [[ ${bfbc2/BFBC2Game.exe/} == $bfbc2 ]]; then
  34.     echo "Starting BFBC2 (steam://rungameid/24960)"
  35. #     setsid env DXVK_HUD=fps,devinfo steam steam://rungameid/24960 & #put in game launch params instead
  36.     setsid steam steam://rungameid/24960 &
  37. fi
  38.  
  39. # ONLY RUN ONE INSTANCE OF THIS SCRIPT
  40. if [[ 1 -ge $(pgrep -fca "/bin/bash $0") ]]; then # if the only instance of this script is this one
  41.     # MANAGE XBINDKEYS    
  42.     echo "$(date +%Y-%m-%d--%H-%M-%S) - XBINDKEYS monitored"
  43.     while sleep 1s; do
  44. #         if [[ "$(xdotool getwindowname $(xdotool getactivewindow) &>/dev/null )" == "Battlefield: Bad Company 2" ]]; then
  45.         if [[ "$(xdotool getwindowname $(xdotool getactivewindow))" == "Battlefield: Bad Company 2" ]]; then        
  46.             if [[ ! $(ps -C xbindkeys -o pid=) ]]; then
  47.                 xbindkeys -f "$xbindkeysFile"
  48.                 echo "$(date +%Y-%m-%d--%H-%M-%S) - XBINDS on"
  49.             fi
  50.         else
  51.             if [[ -n $(ps -C xbindkeys -o pid=) ]]; then
  52.                 killall xbindkeys
  53.                 echo "$(date +%Y-%m-%d--%H-%M-%S) - XBINDS off"        
  54.             fi
  55.         fi
  56.     done
  57. else #already active...exiting
  58.     exit
  59. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top