ubuntuusers.de

change cpu governer ubuntu-12.04

Datum:
22. Juli 2014 22:54
Code:
 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
#!/bin/bash
# made for Ubuntu-12.04, cause i missed the old button to pull down cpu-s
# has to be run as "bash" for the numerical calculation with "let"
#
# first get the current state of the cpu-setting
gov=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`;
#echo "old $gov";
# now toggle the setting - may go wrong if future kernel may change names
# --- but why should they?
# if current cpu setting is ondemand, set new to powersave or set ondemand
if [ "$gov" = "ondemand" ]; then
        gov="powersave";
else
        gov="ondemand";
fi
#echo "new $gov"
# no count thru all available cpu-cores and set the new state
let cpu=0
#for i in 0 1; do
for i in /sys/devices/system/cpu/cpu?; do
#echo "$cpu -   cpufreq-selector -c $i -g $gov"
        cpufreq-selector -c $cpu -g $gov
        let cpu=cpu+1
done
# give some visual response what was done
zenity --notification --text "cpugoverner: $gov" &