op_cpuspeed.sh: Fixed warning message check (from -ge to -gt)
[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 newmhz="$(cat /proc/pandora/cpu_mhz_max)"
8 device=/proc/pandora/cpu_mhz_max
9 if [ ! $1 ]; then
10         if [ $DISPLAY ]; then
11                 newmhz=$(zenity --scale --text "Set CPU clockspeed" --min-value=$minmhz --max-value=$maxmhz --value=$curmhz --step 1)
12         else
13                 newmhz=$(read -p "Please enter the desired clockspeed")
14         fi
15 else
16 newmhz=$1
17 fi
18 if [ $newmhz ]; then
19         if [ $newmhz -gt $safemhz ]; then
20                 if [ $DISPLAY ]; then
21                         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 $?)
22                         echo $answer
23                         if [ $answer = 1 ]; then exit 1; fi
24                 else
25                         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
26                         echo $answer
27                         if [ $answer = n ]; then exit 1; fi
28                 fi
29         fi
30  
31         if [ $newmhz -le $minmhz ]; then newmhz=$minmhz; fi
32         if [ $newmhz -ge $maxmhz ]; then newmhz=$maxmhz; fi
33         echo $newmhz > $device
34         echo cpu_mhz_max set to $(cat /proc/pandora/cpu_mhz_max)
35 fi