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
6 config=$(cat $(grep /etc/passwd -e $(ps u -C xfce4-session | tail -n1 | awk '{print $1}')| cut -f 6 -d ":")/.lidstate)
8 if [[ ! -e /tmp/powerstate || "$(cat /tmp/powerstate)" = "2" ]]; then #do nothing when in powersave mode unless we went into it because of a closed lid
9 if [ "$1" = "1" ]; then #lid was closed
12 /usr/pandora/scripts/op_power.sh 5
15 /usr/pandora/scripts/op_power.sh 1
16 echo "2" > /tmp/powerstate
20 brightness=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
21 if [ $brightness -gt 0 ]; then
22 echo $brightness > /tmp/oldbright
24 echo 0 > /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
25 #echo 1 > /sys/devices/platform/omapfb/graphics/fb0/blank
27 elif [ "$1" = "0" ]; then # lid was opened
30 /usr/pandora/scripts/op_power.sh 1
33 #echo 0 > /sys/devices/platform/omapfb/graphics/fb0/blank
34 #sleep 0.1s # looks cleaner, could flicker without
35 maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
37 if [ -f /tmp/oldbright ]; then
38 oldbright=$(cat /tmp/oldbright)
40 if [ $oldbright -eq 0 ]; then
41 oldbright=$(cat /etc/pandora/conf/brightness.state)
43 if [ $oldbright -ge 3 ] && [ $oldbright -le $maxbright ]; then
44 /usr/pandora/scripts/op_bright.sh $oldbright
46 /usr/pandora/scripts/op_bright.sh $maxbright