op_lid: don't save brightness if it's 0
[pandora-libraries.git] / 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