Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- toggle_cores() {
- # create comma-delimited core list
- a=()
- for ((i=$1; i < ${num_cores}; i++)); do
- a+=(${i})
- done
- delim_cores=$(IFS=,; echo "${a[*]}")
- # turn cores on/off
- taskset -pac ${delim_cores} "${game_pid}"
- }
- # gather core and game info
- num_cores=$(nproc)
- if pgrep "Grim Dawn.exe" > /dev/null 2>&1; then
- game_pid="$(pidof 'Grim Dawn.exe')"
- elif pgrep "GrimInternals64.exe" > /dev/null 2>&1; then
- game_pid="$(pidof 'GrimInternals64.exe')"
- fi
- # toggle Core 0, assuming no issues found
- if [[ ${num_cores} -gt 0 ]]; then
- echo "${num_cores} cores found, continuing..."
- if [[ ${game_pid} -gt 0 ]]; then
- # disable Core 0
- toggle_cores 1
- echo -e "Step 1/2: Core 0 disabled, continuing...\n"
- # wait a bit
- for ((i=8; i >= 0; i--)); do
- echo -e "\e[1A\e[K(waiting ${i} seconds)"
- sleep 1
- done
- # re-enable Core 0
- toggle_cores 0
- echo "Step 2/2: Core 0 re-enabled, process complete!"
- else
- echo "ERROR: Game process not detected (must be running to work)."
- fi
- else
- echo "ERROR: Number of cores couldn't be detected."
- fi
Advertisement
Add Comment
Please, Sign In to add comment