3 minmhz="$(cat /etc/pandora/conf/cpu.conf | grep 'min:' | awk -F\: '{print $2}')"
4 safemhz="$(cat /etc/pandora/conf/cpu.conf | grep 'safe:' | awk -F\: '{print $2}')"
5 maxmhz="$(cat /etc/pandora/conf/cpu.conf | grep 'max:' | awk -F\: '{print $2}')"
6 warn="$(cat /etc/pandora/conf/cpu.conf | grep 'warn:' | awk -F\: '{print $2}')"
7 device=/proc/pandora/cpu_mhz_max
8 curmhz="$(cat $device)"
9 newmhz="$(cat $device)"
11 if [ "$curmhz" -gt "$maxmhz" ]; then
15 if [ "$1" = "-n" ]; then
20 if [ ! -e $device ]; then
21 if [ -z "$1" -a -n "$DISPLAY" ]; then
22 zenity --info --title="CPU-Settings not supported" --text \
23 "Sorry, the experimental kernel does not support setting the clockspeed (yet)."
30 newmhz=$(zenity --scale --text "Set CPU clockspeed" --min-value=$minmhz --max-value=$maxmhz --value=$curmhz --step 1)
32 read -p "Please enter the desired clockspeed: " newmhz
38 if ! [ 0 -lt "$newmhz" -a "$newmhz" -lt 10000 ]; then
39 echo "invalid argument: $newmhz"
44 if [ $newmhz -gt $safemhz ]; then
45 if [ $warn != no ]; then
47 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 $?)
49 if [ $answer = 1 ]; then exit 1; fi
51 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
53 if [ $answer = n ]; then exit 1; fi
58 if [ $newmhz -le $minmhz ]; then newmhz=$minmhz; fi
59 if [ $newmhz -ge $maxmhz ]; then newmhz=$maxmhz; fi
60 echo $newmhz > $device
61 echo "cpu_mhz_max set to $(cat $device)"
63 if [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
64 # must poke cpufreq so it does the actual clock transition
65 # according to new limits
66 gov=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
67 echo $gov > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
68 if [ "$gov" = "userspace" ]; then
69 echo $[ $newmhz * 1000 ] > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
71 echo "current CPU clock is $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)"