op_bluetooth.sh, op_cpusettings.sh, op_cpuspeed.sh: Added notice that these won't...
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_cpuspeed.sh
1 #!/bin/bash
2 #get value range
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 curmhz="$(cat /proc/pandora/cpu_mhz_max)"
8 newmhz="$(cat /proc/pandora/cpu_mhz_max)"
9 device=/proc/pandora/cpu_mhz_max
10 kernel_major=`uname -r | cut -c 1`
11
12 if [ "$kernel_major" = "3" ]; then
13     zenity --info --title="CPU-Settings not supported" --text "Sorry, the experimental kernel does not support setting the clockspeed (yet)."
14     exit 1
15 else
16
17 if [ ! $1 ]; then
18         if [ $DISPLAY ]; then
19                 newmhz=$(zenity --scale --text "Set CPU clockspeed" --min-value=$minmhz --max-value=$maxmhz --value=$curmhz --step 1)
20         else
21                 newmhz=$(read -p "Please enter the desired clockspeed")
22         fi
23 else
24 newmhz=$1
25 fi
26 if [ $newmhz ]; then
27         if [ $newmhz -gt $safemhz ]; then
28                 if [ $warn != no ]; then 
29                         if [ $DISPLAY ]; then
30                                 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 $?)
31                                 echo $answer
32                                 if [ $answer = 1 ]; then exit 1; fi
33                         else
34                                 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
35                                 echo $answer
36                                 if [ $answer = n ]; then exit 1; fi
37                         fi
38                 fi
39         fi
40  
41         if [ $newmhz -le $minmhz ]; then newmhz=$minmhz; fi
42         if [ $newmhz -ge $maxmhz ]; then newmhz=$maxmhz; fi
43         echo $newmhz > $device
44         echo cpu_mhz_max set to $(cat /proc/pandora/cpu_mhz_max)
45 fi
46 fi