Skip to content

Instantly share code, notes, and snippets.

@sunsided
Created July 29, 2021 13:53
Show Gist options
  • Save sunsided/c32e1f33217bce793fc53c9ac4e4391d to your computer and use it in GitHub Desktop.
Save sunsided/c32e1f33217bce793fc53c9ac4e4391d to your computer and use it in GitHub Desktop.
CPU governor selection
#!/usr/bin/env bash
set -eo pipefail
GOVERNORS=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
echo "Available governors:"
echo $GOVERNORS
echo ""
echo "Current governor:"
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# Options: powersave, performance
CPU=$1
if [[ " $GOVERNORS " =~ .*\ $CPU\ .* ]]; then
echo ""
echo "Selecting '$CPU' CPU governor."
echo $CPU | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment