From cb697bb996561aaeeb561c1ec54a29e1e7c5fdbd Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sat, 25 Aug 2012 00:39:23 +0300 Subject: [PATCH] op_power: make sure powersave is off when turning on display --- .../pandora-system/pandora-scripts/op_power.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/recipes/pandora-system/pandora-scripts/op_power.sh b/recipes/pandora-system/pandora-scripts/op_power.sh index 85843d8..35e01cf 100644 --- a/recipes/pandora-system/pandora-scripts/op_power.sh +++ b/recipes/pandora-system/pandora-scripts/op_power.sh @@ -109,6 +109,7 @@ lowPowerOn(){ #switch from normal to lowpower mode lowPowerOff(){ # switch from lowpower to normal mode oldspeed=$(cat /tmp/oldspeed) /usr/pandora/scripts/op_cpuspeed.sh -n $oldspeed + rm -f /tmp/oldspeed display_on resume_net @@ -121,6 +122,18 @@ lowPowerOff(){ # switch from lowpower to normal mode echo 255 > /sys/class/leds/pandora\:\:power/brightness #power LED bright } +display_on_with_checks() { + # after turning on the display, we don't want lowpower state + # (which could be active because of some races) + if [ "$powerstate" = "buttonlowpower" -o "$powerstate" = "lidlowpower" -o \ + -e /tmp/oldspeed ] + then + lowPowerOff + else + display_on + fi +} + show_message() { # TODO: check if desktop is visible; maybe use layer3? xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}') @@ -277,7 +290,7 @@ elif [[ "$2" == "lid" ]]; then powerstate="on" ;; *) - (debug && echo "display_on") || display_on + (debug && echo "display_on") || display_on_with_checks powerstate="on" ;; esac @@ -305,7 +318,8 @@ elif [[ "$2" == "screensaver" ]]; then unset DISPLAY if [[ "$1" == 0 ]]; then # deactivate screensaver - display_on + display_on_with_checks + powerstate="on" elif [[ "$1" == 1 ]]; then # activate screensaver display_off fi -- 2.39.5