-
Notifications
You must be signed in to change notification settings - Fork 1
/
governor
executable file
·120 lines (114 loc) · 2.66 KB
/
governor
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env bash
# Description: Set governor scheduler
# Destination: /usr/local/bin/governor
export LANG=$LANG:C
if [[ $EUID -ne 0 ]]; then
sudo "$0" "$@"
exit 0
fi
if [[ -f "/etc/default/governor" ]]; then
. /etc/default/governor
else
echo 'GOVERNOR="performance"' | tee /etc/default/governor
sleep .25
. /etc/default/governor
fi
if [ $# -eq 0 ]; then
echo "Missing options!"
echo "(run $0 -h for help)"
echo ""
exit 0
fi
while getopts "copsrumh" OPTION; do
case $OPTION in
c)
echo 'GOVERNOR="conservative"' | tee /etc/default/governor > /dev/null 2>&1
. /etc/default/governor
governor -r
;;
o)
echo 'GOVERNOR="ondemand"' | tee /etc/default/governor > /dev/null 2>&1
. /etc/default/governor
governor -r
;;
p)
echo 'GOVERNOR="performance"' | tee /etc/default/governor > /dev/null 2>&1
. /etc/default/governor
governor -r
;;
s)
echo 'GOVERNOR="schedutil"' | tee /etc/default/governor > /dev/null 2>&1
. /etc/default/governor
governor -r
;;
r)
echo "$GOVERNOR" | tee /sys/devices/system/cpu/cpu[0-9]/cpufreq/scaling_governor > /dev/null 2>&1
;;
u)
mv -f /usr/local/bin/governor /usr/local/bin/governor.orig
wget -cq https://raw.githubusercontent.com/pyavitz/scripts/master/governor -P /usr/local/bin/
chmod +x $(command -v governor)
if [[ -f "/usr/local/bin/governor" ]]; then
rm -f /usr/local/bin/governor.orig
else
mv -f /usr/local/bin/governor.orig /usr/local/bin/governor
fi
governor -h
;;
m)
while [ 1 ]
do
CHOICE=$(
export NEWT_COLORS='root=,black roottext=lightgray,black title=black,lightgray'
whiptail --backtitle "Menu Interface: Governor: $GOVERNOR" --title "Governor" --menu "" --nocancel 0 0 0 \
"1)" "Conservative" \
"2)" "Ondemand" \
"3)" "Performance" \
"4)" "Schedutil" \
"E)" "Exit .." 3>&2 2>&1 1>&3
)
case $CHOICE in
"1)")
governor -c
export NEWT_COLORS='root=,black'
whiptail --msgbox " Governor set to Conservative" 0 0
;;
"2)")
governor -o
export NEWT_COLORS='root=,black'
whiptail --msgbox " Governor set to Ondemand" 0 0
;;
"3)")
governor -p
export NEWT_COLORS='root=,black'
whiptail --msgbox " Governor set to Performance" 0 0
;;
"4)")
governor -s
export NEWT_COLORS='root=,black'
whiptail --msgbox " Governor set to Schedutil" 0 0
;;
"E)")
clear -x
exit 0
;;
esac
done
;;
h)
echo -e "\e[1;37mCPU frequency scaling\e[0m"
echo -e "Usage: "
echo ""
echo -e "\t-c\tConservative"
echo -e "\t-o\tOndemand"
echo -e "\t-p\tPerformance"
echo -e "\t-s\tSchedutil"
echo ""
echo -e "\t-r\tRun"
echo -e "\t-u\tUpdate"
echo ""
exit 0
;;
esac
done
exit 0