Skip to content

Instantly share code, notes, and snippets.

@roobre
Created August 14, 2019 16:54
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 roobre/b9e4bb53a6c122197e254fd95a84e876 to your computer and use it in GitHub Desktop.
Save roobre/b9e4bb53a6c122197e254fd95a84e876 to your computer and use it in GitHub Desktop.
Togglegov
#!/bin/bash
if [[ -n $1 ]]; then
[ "root" != "$USER" ] && exec sudo $0 "$@"
read current < /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
read -ra available < /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
next="x"
for i in `seq 0 ${#available[@]}`; do
if [[ ${available[$i]} == $current ]]; then
next=$(( (i + 1) % ${#available[@]}))
fi
done
[ "$next" == "x" ] && exit 1
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
echo ${available[$next]} > $cpu
done
fi
read current < /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
case $current in
"powersave")
echo -n ' '
;;
"performance")
echo -n ' '
;;
esac
echo ${current^}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment