libpnd; make pndvalidator slightly less useless.. can illustrate some pnd iteration
[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 #may also be called after inactivity, like X DPMS
5
6 if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode
7   if [ "$1" = "1" ]; then #lid was closed
8     brightness=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
9     if [ $brightness -gt 0 ]; then
10       echo $brightness > /tmp/oldbright
11     fi
12     echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
13     #echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
14   elif [ "$1" = "0" ]; then # lid was opened
15     #echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
16     #sleep 0.1s # looks cleaner, could flicker without
17     maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
18     oldbright=0
19     if [ -f /tmp/oldbright ]; then
20       oldbright=$(cat /tmp/oldbright)
21     fi
22     if [ $oldbright -eq 0 ]; then
23       oldbright=$(cat /etc/pandora/conf/brightness.state)
24     fi
25      if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then 
26       /usr/pandora/scripts/op_bright.sh $oldbright 
27      else
28       /usr/pandora/scripts/op_bright.sh $maxbright
29      fi
30   fi
31 fi