pandora-scripts: Tweaks to helper scripts.
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_cpuspeed.sh
1 #!/bin/bash
2 #get value range
3 minmhz=14
4 safemhz=600
5 maxmhz=900
6 curmhz=$(cat /proc/pandora/cpu_mhz_max)
7 device=/proc/pandora/cpu_mhz_max
8 if [ ! $1 ]; then
9         if [ $DISPLAY ]; then
10                 newmhz=$(zenity --scale --text "set cpu mhz" --min-value=$minmhz --max-value=$maxmhz --value=$curmhz --step 1)
11         else
12                 newmhz=$(read -p "Pleas enter the desired speed")
13         fi
14 else
15 newmhz=$1
16 fi
17 if [ $newmhz ]; then
18         if [ $newmhz -ge $safemhz ]; then
19                 if [ $DISPLAY ]; then
20                         answer=$(zenity --question --title "Alert" --text "You are trying to set the cpu clock to $newmhz which is above its specification of $safemhz, doing so may burn down your house, sour milk, or just blow up (ok, not that likely)! proceed?";echo $?)
21                         echo $answer
22                         if [ $answer = 1 ]; then exit 1; fi
23                 else
24                         answer="n";read -p "You are trying to set the cpu clock to $newmhz which is above its specification 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
25                         echo $answer
26                         if [ $answer = n ]; then exit 1; fi
27                 fi
28         fi
29  
30         if [ $newmhz -le $minmhz ]; then newmhz=$minmhz; fi
31         if [ $newmhz -ge $maxmhz ]; then newmhz=$maxmhz; fi
32 fi
33 echo $newmhz > $device
34 echo cpu_mhz_max set to $(cat /proc/pandora/cpu_mhz_max)