67d4ba4c0c79717234f998dc422f9eae1613cc31
[pandora-libraries.git] / testdata / scripts / op_lid.sh
1 #!/bin/bash
2 #actions done when the lid is closed
3 #only argument is 0 for open 1 for closed
4
5 if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode
6   if [ "$1" = "1" ]; then #lid was closed
7     #/usr/pandora/scripts/op_bright.sh 0
8     cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness > /tmp/oldbright
9     echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
10     echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
11   elif [ "$1" = "0" ]; then # lid was opend
12     echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
13     sleep 0.1s # looks cleaner, could flicker without
14     maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
15     oldbright=$(cat /tmp/oldbright)
16      if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then 
17       /usr/pandora/scripts/op_bright.sh $oldbright 
18      else
19       /usr/pandora/scripts/op_bright.sh $maxbright
20      fi
21   fi
22 fi