Last active
October 30, 2017 20:55
-
-
Save NeoTheFox/70001b5cbf33be4b2bf25b5509e0697a to your computer and use it in GitHub Desktop.
A script to switch the governor if steam is running
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 | |
GOVERNOR=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) | |
if [ $1 == "-d" ] | |
then | |
while : | |
do | |
GOVERNOR=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) | |
if [ -n "$(pgrep steam)" ] | |
then | |
if [ $GOVERNOR == "schedutil" ] | |
then | |
echo "Steam is running, switching to performance" | |
sudo cpupower frequency-set -g performance || echo "Setting governor failed!" | |
elif [ $GOVERNOR == "performance" ] | |
then | |
continue | |
else | |
echo "Unknown governor, shutting down in panic!" | |
exit 1 | |
fi | |
else | |
if [ $GOVERNOR == "schedutil" ] | |
then | |
continue | |
elif [ $GOVERNOR == "performance" ] | |
then | |
echo "Steam is not running, switching to schedutil" | |
sudo cpupower frequency-set -g schedutil || echo "Setting governor failed!" | |
else | |
echo "Unknown governor, shutting down in panic!" | |
exit 1 | |
fi | |
fi | |
sleep 5 | |
done | |
exit 0 | |
fi | |
if [ $GOVERNOR == "performance" ] | |
then | |
echo "Switching to schedutil" | |
sudo cpupower frequency-set -g schedutil || echo "Setting governor failed!" | |
elif [ $GOVERNOR == "schedutil" ] | |
then | |
echo "Switching to performance" | |
sudo cpupower frequency-set -g performance || echo "Setting governor failed" | |
else | |
echo "Unknown governor, shutting down in panic" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment