2 #actions done when the power button is pressed
3 #only argument is the time the button was pressed in seconds
5 if [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend"
6 powerstate=$(cat /tmp/powerstate)
7 if [$powerstate -eq "1" ]; then
9 echo 0 > /tmp/powerstate
10 oldbright=$(cat /tmp/oldbright)
11 maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
12 oldspeed=$(cat /tmp/oldspeed)
13 if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then
14 /usr/pandora/scripts/op_bright.sh $oldbright
16 /usr/pandora/scripts/op_bright.sh $maxbright
18 if [ $oldspeed -ge 14 ] && [ $oldspeed -le 1000 ]; then
19 echo $oldspeed > /proc/pandora/cpu_mhz_max
21 echo 500 > /proc/pandora/cpu_mhz_max
23 pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
26 kill -18 $PID #send SIGCONT
30 echo 1 > /tmp/powerstate
31 cat /proc/pandora/cpu_mhz_max > /tmp/oldspeed
32 cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright
33 pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p')
36 kill -19 $PID #send SIGSTOP
39 /etc/init.d/S30wlxxx-init stop
40 echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
41 echo 14 > /proc/pandora/cpu_mhz_max
43 elif [ "$1" -ge "4" ]; then #button was pressed 4 sec or longer, shutdown