Created
July 1, 2022 19:20
-
-
Save mrdev023/59f9ef9b40101745a645ce875697b79d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function enable_core() { | |
bash -c "echo 1 > \"/sys/devices/system/cpu/cpu$1/online\"" | |
echo "Set Core $1 : enabled" | |
} | |
function disable_core() { | |
bash -c "echo 0 > \"/sys/devices/system/cpu/cpu$1/online\"" | |
echo "Set Core $1 : disabled" | |
} | |
function enable_game_mode() { | |
if [ "$UID" != "0" ]; then | |
echo "Run this script as root" | |
else | |
numberOfCores=$(nproc --all) | |
for ((x=0; x < $numberOfCores; x++)); do | |
if [ $(( $x % 2 )) -eq 0 ]; then | |
enable_core $x | |
else | |
disable_core $x | |
fi | |
done | |
fi | |
} | |
function disable_game_mode() { | |
if [ "$UID" != "0" ]; then | |
echo "Run this script as root" | |
else | |
numberOfCores=$(nproc --all) | |
for ((x=0; x < $numberOfCores; x++)); do | |
enable_core $x | |
done | |
fi | |
} | |
if [ "$1" == "enable" ]; then | |
enable_game_mode | |
else | |
disable_game_mode | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want add it with gamemode
gamemode.ini