Skip to content

Instantly share code, notes, and snippets.

@szampardi
Created July 10, 2024 16:30
Show Gist options
  • Save szampardi/3567df0b11eb2bbaeda22605f9515536 to your computer and use it in GitHub Desktop.
Save szampardi/3567df0b11eb2bbaeda22605f9515536 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
GOVERNOR=${2:-conservative}
n=0
case "${1}" in
s | set)
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
printf 'CPU%d\t[ %s -> %s ]\n' ${n} $(<"/sys/devices/system/cpu/cpu${n}/cpufreq/scaling_governor") "${GOVERNOR}"
echo "${GOVERNOR}" >/sys/devices/system/cpu/cpu${n}/cpufreq/scaling_governor
n=$((n+1))
done
;;
l | ls | list)
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors; do
printf 'CPU%d\t[ %s ]\n' ${n} "$(</sys/devices/system/cpu/cpu${n}/cpufreq/scaling_available_governors)"
n=$((n + 1))
done
;;
*)
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
printf 'CPU%d:\t%s\n' ${n} "$(</sys/devices/system/cpu/cpu${n}/cpufreq/scaling_governor)"
n=$((n + 1))
done
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment