X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=testdata%2Fscripts%2Fop_power.sh;h=34bf3762d34a6bbf7b1fcec76fda4c27f94f23ff;hb=ed7e9f06b818b83750b1c7531bd8d2fe3adfb259;hp=a28c9a1b8f6995472b921e9e94253ba7816d2435;hpb=857b445341c922ab797e0f9d9866a91f21c0118e;p=pandora-libraries.git diff --git a/testdata/scripts/op_power.sh b/testdata/scripts/op_power.sh old mode 100644 new mode 100755 index a28c9a1..34bf376 --- a/testdata/scripts/op_power.sh +++ b/testdata/scripts/op_power.sh @@ -1,22 +1,52 @@ #!/bin/bash -#actions done when the menu button is pressed +#actions done when the power button is pressed #only argument is the time the button was pressed in seconds -if [ "$1" -le "1" ]; then #button was pressed 1 sec or less, resume - pndrunning=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p') - for PID in $pidlist - do - kill -18 $PID #send SIGCONT - done - /usr/pandora/scripts/op_cpuspeed 500 -elif [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend" - pndrunning=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p') - for PID in $pidlist - do - kill -19 $PID #send SIGSTOP - done - /usr/pandora/scripts/op_cpuspeed 13 -elif [ "$1" -ge "3" ]; then #button was pressed 3 sec or longer, shutdown +if [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend" + if [ -e /tmp/powerstate ]; then + powerstate=$(cat /tmp/powerstate) + else + powerstate=0 + fi + if [$powerstate -eq 1 ]; then + #in lowpower mode + echo 0 > /tmp/powerstate + oldbright=$(cat /tmp/oldbright) + maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness) + oldspeed=$(cat /tmp/oldspeed) + if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then + /usr/pandora/scripts/op_bright.sh $oldbright + else + /usr/pandora/scripts/op_bright.sh $maxbright + fi + if [ $oldspeed -ge 14 ] && [ $oldspeed -le 1000 ]; then + echo $oldspeed > /proc/pandora/cpu_mhz_max + else + echo 500 > /proc/pandora/cpu_mhz_max + fi + hciconfig hci0 up + /etc/init.d/S30wlxxx-init start + pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p') + for PID in $pidlist + do + kill -18 $PID #send SIGCONT + done + else + #in normal mode + echo 1 > /tmp/powerstate + cat /proc/pandora/cpu_mhz_max > /tmp/oldspeed + cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright + pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p') + for PID in $pidlist + do + kill -19 $PID #send SIGSTOP + done + hciconfig hci0 down + /etc/init.d/S30wlxxx-init stop + echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness + echo 14 > /proc/pandora/cpu_mhz_max + fi +elif [ "$1" -ge "4" ]; then #button was pressed 4 sec or longer, shutdown shutdown -h now fi