Created
August 14, 2019 16:54
-
-
Save roobre/b9e4bb53a6c122197e254fd95a84e876 to your computer and use it in GitHub Desktop.
Togglegov
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 | |
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