From 303fbe209ab8aa5f26224a18873d84e28fa8c305 Mon Sep 17 00:00:00 2001 From: vimacs Date: Thu, 11 Mar 2010 16:56:17 +0100 Subject: [PATCH] only turn on wl/bt if it was on before modified: testdata/scripts/op_power.sh --- testdata/scripts/op_power.sh | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/testdata/scripts/op_power.sh b/testdata/scripts/op_power.sh index 0cc8188..dfee8e5 100755 --- a/testdata/scripts/op_power.sh +++ b/testdata/scripts/op_power.sh @@ -2,7 +2,7 @@ #actions done when the power button is pressed #only argument is the time the button was pressed in seconds -if [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend" +if [ "$1" -le "2" ]; then # button was pressed 1-2sec, "suspend" if [ -e /tmp/powerstate ]; then powerstate=$(cat /tmp/powerstate) else @@ -19,13 +19,19 @@ if [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend" else /usr/pandora/scripts/op_bright.sh $maxbright fi - if [ $oldspeed -gt 14 ] && [ $oldspeed -le 1000 ]; then + if [ $oldspeed -gt 14 ] && [ $oldspeed -le 900 ]; then echo $oldspeed > /proc/pandora/cpu_mhz_max else echo 500 > /proc/pandora/cpu_mhz_max fi - hciconfig hci0 up - /etc/init.d/wl1251-init start + hcistate=$(cat /tmp/hcistate) + if [ ! $hcistate ]; then + hciconfig hci0 up + fi + wlstate=$(cat /tmp/wlstate) + if [ ! $wlstate ]; then + /etc/init.d/wl1251-init start + fi pidlist=$(pstree -lpA | grep pnd_run.sh | sed -ne 's/.*(\([0-9]\+\))/\1/p') for PID in $pidlist do @@ -41,19 +47,31 @@ if [ "$1" -le "3" ]; then # button was pressed 1-3sec, "suspend" do kill -19 $PID #send SIGSTOP done - hciconfig hci0 down - /etc/init.d/wl1251-init stop + rm /tmp/hcistate + hcistate=$(hciconfig hci0 | grep DOWN) + if [ $hcistate ]; then + echo "down" > /tmp/hcistate + else + hciconfig hci0 down + fi + rm /tmp/wlstate + wlstate=$(lsmod | grep -m1 wl1251) + if [ ! $wlstate ]; then + echo "down" > /tmp/wlstate + else + /etc/init.d/wl1251-init stop + fi 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 +elif [ "$1" -ge "3" ]; then #button was pressed 3 sec or longer, shutdown xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}') time=10 countdown () { for i in $(seq $time); do precentage=$(echo $i $time | awk '{ printf("%f\n", $1/$2*100) }') echo $precentage - echo "# Shutdown in $i" + echo "# Shutdown in $(($time-$i))" sleep 1 done } -- 2.39.5