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