mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 22:23:27 +00:00
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>
This commit is contained in:
parent
db9f26cfcb
commit
102855b3c1
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user