-
Notifications
You must be signed in to change notification settings - Fork 4
/
underclock.sh
executable file
·55 lines (48 loc) · 994 Bytes
/
underclock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
LOW_FREQ="1.6GhZ"
MAX_FREQ="3.0GhZ"
LOW_GOV="powersave"
MAX_GOV="performance"
NPROC=`nproc`
usage() {
SCRIPT_NAME=`echo $0 | sed -r -e "s/.*\///"`
echo "Usage: $SCRIPT_NAME [print|unset|set [freq][MhZ|GhZ]]"
echo "With no argument underclocks CPU."
}
underclock() {
for i in `seq 0 $(( $NPROC - 1))`; do
echo "Setting cpu $i to ${1} (${2})."
sudo cpufreq-set -c $i -u $1
sudo cpufreq-set -c $i -g $2
done
}
printstatus() {
for i in `seq 0 $(( NPROC - 1))`; do
var=`cpufreq-info -c $i -p`
arr=($var)
min=${arr[0]}
max=${arr[1]}
gov=${arr[2]}
freq=`cpufreq-info -c $i -f -m`
min=$(( $min / 1000 ))
max=$(( $max / 1000 ))
echo "CPU $i: Running at ${freq}, min is ${min}MhZ, max is ${max}MhZ. Governor is $gov."
done
}
if [[ $# > 2 ]] ; then
usage
exit 1
fi
case $1 in
"print") printstatus
;;
"unset") underclock $MAX_FREQ $MAX_GOV
;;
"set") underclock $2 $LOW_GOV
;;
"") underclock $LOW_FREQ $LOW_GOV
;;
*) usage
exit 1
;;
esac