Skip to content

Instantly share code, notes, and snippets.

@NeoTheFox
Last active October 30, 2017 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeoTheFox/70001b5cbf33be4b2bf25b5509e0697a to your computer and use it in GitHub Desktop.
Save NeoTheFox/70001b5cbf33be4b2bf25b5509e0697a to your computer and use it in GitHub Desktop.
A script to switch the governor if steam is running
#!/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