aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2024-02-01 11:17:17 +0100
committerFlorian Eckert <fe@dev.tdt.de>2024-02-07 15:34:43 +0100
commit102855b3c13e4fc6b1df4325ee51855a69874f88 (patch)
tree5d7f865ddee99a24cb8a97e6e49c1b258cc3d250
parentdb9f26cfcb5d5222a68f60fc30958f61d18057f2 (diff)
base-files/leds: save led color value if available
There are monochrome LEDs that can only display one color. However, there are also LEDs that can display multiple colors. This can be tested in the led subsystem of the kernel if the files 'multi_index' and 'multi_intensity' are present in the folder '/sys/class/leds/<ledname>'. Until now it was not possible to reset the default color. This commit adds the missing information in the file '/var/run/led.state' so that the bootup color can be seen on the LED again when the LED configuration has been changed. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
-rwxr-xr-xpackage/base-files/files/etc/init.d/led17
1 files changed, 14 insertions, 3 deletions
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index 08a1e6df3b..d7fee9ebb2 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -49,11 +49,18 @@ load_led() {
[ -e /sys/class/leds/${sysfs}/brightness ] && {
echo "setting up led ${name}"
- printf "%s %s %d\n" \
+ printf "%s %s %d" \
"$sysfs" \
"$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \
"$(cat /sys/class/leds/${sysfs}/brightness)" \
>> /var/run/led.state
+ # Save default color if supported
+ [ -e /sys/class/leds/${sysfs}/multi_intensity ] && {
+ printf " %s" \
+ "$(sed 's/\ /:/g' /sys/class/leds/${sysfs}/multi_intensity)" \
+ >> /var/run/led.state
+ }
+ printf "\n" >> /var/run/led.state
[ "$default" = 0 ] &&
echo 0 >/sys/class/leds/${sysfs}/brightness
@@ -128,13 +135,17 @@ load_led() {
start() {
[ -e /sys/class/leds/ ] && {
[ -s /var/run/led.state ] && {
- local led trigger brightness
- while read led trigger brightness; do
+ local led trigger brightness color
+ while read led trigger brightness color; 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"
+
+ [ -e "/sys/class/leds/$led/multi_intensity" ] && \
+ echo "$color" | sed 's/:/\ /g' > \
+ "/sys/class/leds/$led/multi_intensity"
done < /var/run/led.state
rm /var/run/led.state
}