[OpenPandora] CPU Takt ändern

Shellscript  (02.08.2011 15:25) Ändert den CPU Takt der Pandora.
Aufruf:
setmhz.sh toggle # Wechselt zwischen definierten Minimum und Maximum
setmhz.sh display # Zeigt den aktuellen Takt in einem notify an
setmhz.sh 200 # Setzt den Takt auf 200 MHz

Quellcode (ausblenden | aufklappen)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
 
showmsg() {
   path="/usr/share/icons/gnome/scalable"
   icon="$1"
   title="$2"
   msg="$3"
 
   notify-send -u normal "$title" "$msg" -i "$path/$icon" -t 5000
   return 0;
}
 
device="/proc/pandora/cpu_mhz_max"
minmhz="$(cat /etc/pandora/conf/cpu.conf | grep "min:" | awk -F\: '{print $2}')"
maxmhz="$(cat /etc/pandora/conf/cpu.conf | grep "max:" | awk -F\: '{print $2}')"
defmhz="$(cat /etc/pandora/conf/cpu.conf | grep "default:" | awk -F\: '{print $2}')"
curmhz="$(cat /proc/pandora/cpu_mhz_max)"
newmhz="$(cat /proc/pandora/cpu_mhz_max)"
mhz="$1"
 
# toggle between default and max
if [ "$mhz" == "toggle" ]; then
   if [ "$curmhz" -gt "$defmhz" ] || [ "$curmhz" -lt "$defmhz" ]; then
      $0 $defmhz
   else
      $0 $maxmhz
   fi
   exit 0;
fi
 
# display current mhz
if [ "$mhz" == "display" ]; then
   showmsg "apps/gnome-monitor.svg" "CPU Speed" "CPU speed is $(cat $device) MHz"
   exit 0;
fi
 
# set custom mhz value
if [ "$mhz" -ge "$minmhz" ] && [ "$mhz" -le "$maxmhz" ]; then
   echo $mhz > $device
   showmsg "apps/gnome-monitor.svg" "CPU Speed" "Setting speed to $mhz MHz..."
else
   showmsg "apps/gnome-monitor.svg" "CPU Speed" "Given speed out of range!"
fi