op_lid: Doesn't do anything while in powersaving-mode
[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   elif [ "$1" = "0" ]; then # lid was opend
11     maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
12     oldbright=$(cat /tmp/oldbright)
13      if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then 
14       /usr/pandora/scripts/op_bright.sh $oldbright 
15      else
16       /usr/pandora/scripts/op_bright.sh $maxbright
17      fi
18   fi
19 fi