+is_lid_open() {
+ if [ -x /usr/bin/op_lidstate -a ! -e /etc/pandora/my_lid_is_broken ]; then
+ if [ $(op_lidstate) = "0" ]; then
+ # lid is open - return true
+ return 0
+ else
+ # lid is closed - return false
+ return -1
+ fi
+ else
+ # op_lidstate program not found, report lid open
+ # this should cause less trouble
+ return 0
+ fi
+}
+
+powerstate_try_on() {
+ # if lid is open switch powerstate to "on"
+ # if lid is closed switch powerstate to "liddisplayoff"
+ # this prevents screen off lock when shoulder butttons
+ # are pressed while the lid is closed
+ if is_lid_open; then
+ powerstate="on"
+ else
+ powerstate="liddisplayoff"
+ fi
+}
+