3 cpu_conf=/etc/pandora/conf/cpu.conf
4 minmhz="$(grep '^min:' $cpu_conf | awk -F\: '{print $2}')"
5 safemhz="$(grep '^safe:' $cpu_conf | awk -F\: '{print $2}')"
6 maxmhz="$(grep '^max:' $cpu_conf | awk -F\: '{print $2}')"
7 warn="$(grep '^warn:' $cpu_conf | awk -F\: '{print $2}')"
8 device=/proc/pandora/cpu_mhz_max
9 curmhz="$(cat $device)"
10 newmhz="$(cat $device)"
12 if [ "$curmhz" -gt "$maxmhz" ]; then
16 if [ "$1" = "-n" ]; then
21 if [ ! -e $device ]; then
22 if [ -z "$1" -a -n "$DISPLAY" ]; then
23 zenity --info --title="CPU-Settings not supported" --text \
24 "Sorry, the experimental kernel does not support setting the clockspeed (yet)."
31 newmhz=$(zenity --scale --title "CPU clockspeed" --text "Set CPU clockspeed" --min-value=$minmhz --max-value=$maxmhz --value=$curmhz --step 1)
33 read -p "Please enter the desired clockspeed: " newmhz
39 if ! [ 0 -lt "$newmhz" -a "$newmhz" -lt 10000 ]; then
40 echo "invalid argument: $newmhz"
45 if [ $newmhz -gt $safemhz ]; then
46 if [ $warn != no ]; then
48 answer=$(zenity --question --title "Alert" --text "You are trying to set the CPU clock to $newmhz which is above the warning level of $safemhz, doing so may burn down your house, sour milk, or just blow up (OK, not that likely)! Proceed?";echo $?)
50 if [ $answer = 1 ]; then exit 1; fi
52 answer="n";read -p "You are trying to set the CPU clock to $newmhz which is above the warning level of $safemhz, doing so may burn down your house, sour milk, or just blow up (OK, not that likely)! Proceed? [y/n]" -t 10 answer
54 if [ $answer = n ]; then exit 1; fi
59 if [ $newmhz -le $minmhz ]; then newmhz=$minmhz; fi
60 if [ $newmhz -ge $maxmhz ]; then newmhz=$maxmhz; fi
61 echo $newmhz > $device
62 echo "cpu_mhz_max set to $(cat $device)"
64 if [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
65 # must poke cpufreq so it does the actual clock transition
66 # according to new limits
67 gov=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
68 echo $gov > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
69 if [ "$gov" = "userspace" ]; then
70 echo $[ $newmhz * 1000 ] > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
72 echo "current CPU clock is $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)"