From 0382d0f40d560e69b6462a1a3f185a2e38baf9d2 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Fri, 27 Aug 2010 18:36:14 +0300 Subject: [PATCH] op_lid: handle spurious 'open' calls The script should now be able to handle open and close events in any order. --- testdata/scripts/op_lid.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/testdata/scripts/op_lid.sh b/testdata/scripts/op_lid.sh index a070d49..5f78072 100755 --- a/testdata/scripts/op_lid.sh +++ b/testdata/scripts/op_lid.sh @@ -1,6 +1,7 @@ #!/bin/bash #actions done when the lid is closed #only argument is 0 for open 1 for closed +#may also be called after inactivity, like X DPMS if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode if [ "$1" = "1" ]; then #lid was closed @@ -10,11 +11,17 @@ if [ ! -e /tmp/powerstate ]; then #do nothing when in powersave mode 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 + elif [ "$1" = "0" ]; then # lid was opened echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank sleep 0.1s # looks cleaner, could flicker without maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness) - oldbright=$(cat /tmp/oldbright) + oldbright=0 + if [ -f /tmp/oldbright ]; then + oldbright=$(cat /tmp/oldbright) + fi + if [ $oldbright -eq 0 ]; then + oldbright=$(cat /etc/pandora/conf/brightness.state) + fi if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then /usr/pandora/scripts/op_bright.sh $oldbright else -- 2.39.2