op_lid: don't save brightness if it's 0
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 22 Aug 2010 19:36:53 +0000 (22:36 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 22 Aug 2010 19:36:53 +0000 (22:36 +0300)
this way op_lid can be called multiple times with same argument.

testdata/scripts/op_lid.sh

index 67d4ba4..a070d49 100755 (executable)
@@ -4,8 +4,10 @@
 
 if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode
   if [ "$1" = "1" ]; then #lid was closed
-    #/usr/pandora/scripts/op_bright.sh 0
-    cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright
+    brightness=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
+    if [ $brightness -gt 0 ]; then
+      echo $brightness > /tmp/oldbright
+    fi
     echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
     echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
   elif [ "$1" = "0" ]; then # lid was opend