Guest User

gd_core_toggler.sh

a guest
Dec 5th, 2023
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.09 KB | Gaming | 0 0
  1. #!/usr/bin/env bash
  2. toggle_cores() {
  3.     # create comma-delimited core list
  4.     a=()
  5.     for ((i=$1; i < ${num_cores}; i++)); do
  6.         a+=(${i})
  7.     done
  8.     delim_cores=$(IFS=,; echo "${a[*]}")
  9.     # turn cores on/off
  10.     taskset -pac ${delim_cores} "${game_pid}"
  11. }
  12.  
  13. # gather core and game info
  14. num_cores=$(nproc)
  15. if pgrep "Grim Dawn.exe" > /dev/null 2>&1; then
  16.     game_pid="$(pidof 'Grim Dawn.exe')"
  17. elif pgrep "GrimInternals64.exe" > /dev/null 2>&1; then
  18.     game_pid="$(pidof 'GrimInternals64.exe')"
  19. fi
  20.  
  21. # toggle Core 0, assuming no issues found
  22. if [[ ${num_cores} -gt 0 ]]; then
  23.     echo "${num_cores} cores found, continuing..."
  24.     if [[ ${game_pid} -gt 0 ]]; then
  25.         # disable Core 0
  26.         toggle_cores 1
  27.         echo -e "Step 1/2: Core 0 disabled, continuing...\n"
  28.         # wait a bit
  29.         for ((i=8; i >= 0; i--)); do
  30.             echo -e "\e[1A\e[K(waiting ${i} seconds)"
  31.             sleep 1
  32.         done
  33.         # re-enable Core 0
  34.         toggle_cores 0
  35.         echo "Step 2/2: Core 0 re-enabled, process complete!"
  36.     else
  37.         echo "ERROR: Game process not detected (must be running to work)."
  38.     fi
  39. else
  40.     echo "ERROR: Number of cores couldn't be detected."
  41. fi
Advertisement
Add Comment
Please, Sign In to add comment