pandora-scripts: dim the LED on idle too
authorGrazvydas Ignotas <notasas@gmail.com>
Sat, 14 May 2016 22:18:44 +0000 (01:18 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sat, 14 May 2016 22:18:44 +0000 (01:18 +0300)
recipes/pandora-system/pandora-scripts/led.conf
recipes/pandora-system/pandora-scripts/op_power.sh

index 0401d07..88ca1a8 100644 (file)
@@ -7,8 +7,13 @@ xfceuser_home=$(get_user_home)
 # XXX: better use lockfile (or something), but it's not in current firmware
 test -e /tmp/op_power.lock && exit 2
 touch /tmp/op_power.lock
-highpow="$(cat /etc/pandora/conf/led.conf | grep HighPowerLED: | awk -F\: '{print $2}')"
-lowpow="$(cat /etc/pandora/conf/led.conf | grep LowPowerLED: | awk -F\: '{print $2}')"
+
+led_high="$(cat /etc/pandora/conf/led.conf | grep HighPowerLED: | awk -F\: '{print $2}')"
+led_low="$(cat /etc/pandora/conf/led.conf | grep LowPowerLED: | awk -F\: '{print $2}')"
+led_idle="$(cat /etc/pandora/conf/led.conf | grep IdleLED: | awk -F\: '{print $2}')"
+test -z "$led_high" && led_high=255
+test -z "$led_low" && led_low=16
+test -z "$led_idle" && led_idle=48
 
 debug(){
        return 1 # 0 when debugging, 1 when not
@@ -123,7 +128,7 @@ lowPowerOff(){ # switch from lowpower to normal mode
        do
                kill -CONT $PID
        done
-       echo $highpow > /sys/class/leds/pandora\:\:power/brightness #power LED bright
+       echo $led_high > /sys/class/leds/pandora\:\:power/brightness #power LED bright
 }
 
 display_on_with_checks() {
@@ -135,6 +140,7 @@ display_on_with_checks() {
                lowPowerOff
        else
                display_on
+               echo $led_high > /sys/class/leds/pandora\:\:power/brightness
        fi
 }
 
@@ -224,7 +230,7 @@ Please do not remove SD cards while pandora is suspended, doing so will corrupt
 
        display_on
        resume_net
-       echo $highpow > /sys/class/leds/pandora\:\:power/brightness
+       echo $led_high > /sys/class/leds/pandora\:\:power/brightness
 
        # wait here a bit to prevent this script from running again (keep op_power.lock)
        # in case user did resume using the power switch.
@@ -235,7 +241,7 @@ Please do not remove SD cards while pandora is suspended, doing so will corrupt
 
 suspend_() {
        # dim power LED
-       echo $lowpow > /sys/class/leds/pandora\:\:power/brightness
+       echo $led_low > /sys/class/leds/pandora\:\:power/brightness
 
        if suspend_real; then
                # resumed already
@@ -315,6 +321,7 @@ elif [[ "$2" == "lid" ]]; then
                                ;;
                                *)
                                        (debug && echo "display_off") || display_off
+                                       echo $led_idle > /sys/class/leds/pandora\:\:power/brightness
                                        powerstate="liddisplayoff"
                                ;;
                        esac
@@ -330,6 +337,7 @@ elif [[ "$2" == "screensaver" ]]; then
                powerstate="on"
        elif [[ "$1" == 1 ]]; then # activate screensaver
                display_off
+               echo $led_idle > /sys/class/leds/pandora\:\:power/brightness
        fi
 fi