summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2016-06-08 10:14:27 +0200
committerJo-Philipp Wich <jo@mein.io>2016-06-08 10:34:50 +0200
commit35b33f0413c9f6a263549d63b2b068d74543d876 (patch)
tree54050e056169759a493252f398e89f8711a521a9 /package
parent98d418e05f0bf488b14adabffe6db200b7394a1c (diff)
downloadmtk-20170518-35b33f0413c9f6a263549d63b2b068d74543d876.zip
mtk-20170518-35b33f0413c9f6a263549d63b2b068d74543d876.tar.gz
mtk-20170518-35b33f0413c9f6a263549d63b2b068d74543d876.tar.bz2
base-files: maintain LED config state
Record the state of any hardware LED configured through UCI and use that information to revert the state when applying updated settings while maintaining default behaviour of system LEDs. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'package')
-rwxr-xr-xpackage/base-files/files/etc/init.d/led22
1 files changed, 17 insertions, 5 deletions
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index a6be788..1d10f72 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -37,6 +37,12 @@ load_led() {
[ -e /sys/class/leds/${sysfs}/brightness ] && {
echo "setting up led ${name}"
+ printf "%s %s %d\n" \
+ "$sysfs" \
+ "$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \
+ "$(cat /sys/class/leds/${sysfs}/brightness)" \
+ >> /var/run/led.state
+
[ "$default" = 0 ] &&
echo 0 >/sys/class/leds/${sysfs}/brightness
@@ -103,11 +109,17 @@ load_led() {
start() {
[ -e /sys/class/leds/ ] && {
- local led
- for led in /sys/class/leds/*; do
- [ -e "$led/trigger" ] && echo "none" > "$led/trigger"
- [ -e "$led/brightness" ] && echo "0" > "$led/brightness"
- done
+ [ -s /var/run/led.state ] && {
+ local led trigger brightness
+ while read led trigger brightness; do
+ [ -e "/sys/class/leds/$led/trigger" ] && \
+ echo "$trigger" > "/sys/class/leds/$led/trigger"
+
+ [ -e "/sys/class/leds/$led/brightness" ] && \
+ echo "$brightness" > "/sys/class/leds/$led/brightness"
+ done < /var/run/led.state
+ rm /var/run/led.state
+ }
config_load system
config_foreach load_led led