Last active
July 8, 2022 02:12
-
-
Save ganadist/bac5f574468de422df59 to your computer and use it in GitHub Desktop.
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 | |
ID=`id -u` | |
if [ $ID != 0 ]; then | |
exec sudo $0 $@ | |
fi | |
print_available_governors() { | |
echo -n "available governors are : " | |
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | |
echo -n "current governor is : " | |
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor | |
echo | |
} | |
set_governor() { | |
GOVERNOR=$1 | |
for F in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | |
do | |
echo $GOVERNOR > $F 2>&1 || print_available_governors || exit 1 | |
done | |
} | |
case "$@" in | |
'p' | 'perf' | 'performance') | |
GOVERNOR='performance' | |
;; | |
's' | 'save' | 'powersave') | |
GOVERNOR='powersave' | |
;; | |
'u' | 'user' | 'userspace') | |
GOVERNOR='userspace' | |
;; | |
'c' | 'cons' | 'conservative') | |
GOVERNOR='conservative' | |
;; | |
*) | |
echo "Usage: $0 GOVERNOR" | |
echo | |
print_available_governors | |
exit 1 | |
;; | |
esac | |
set_governor $GOVERNOR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment