-
Notifications
You must be signed in to change notification settings - Fork 2
/
set-cpu-mode.sh
executable file
·42 lines (40 loc) · 1.19 KB
/
set-cpu-mode.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
#!/bin/sh
i=0
nproc=`nproc`
if [ $# -eq 0 ]
then
echo "======================== HOW TO USE ========================"
echo "$0 [0:check status,1:performance,2:powersave]"
echo "============================================================"
else
# check status
if [ $1 -eq 0 ]
then
while [ $i -lt $(nproc) ]
do
sudo echo "CPU$i:" `cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor`
i=`expr $i + 1`
done
# performance mode
elif [ $1 -eq 1 ]
then
while [ $i -lt $(nproc) ]
do
echo performance | sudo tee /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor > /dev/null
sudo echo "CPU$i:" `cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor`
i=`expr $i + 1`
done
# powersave mode
elif [ $1 -eq 2 ]
then
while [ $i -lt $(nproc) ]
do
echo powersave | sudo tee /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor > /dev/null
sudo echo "CPU$i:" `cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor`
i=`expr $i + 1`
done
# input error
else
echo "Input error!"
fi
fi