Skip to content
Snippets Groups Projects
Commit 35b33f04 authored by Jo-Philipp Wich's avatar Jo-Philipp Wich
Browse files

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: default avatarJo-Philipp Wich <jo@mein.io>
parent 98d418e0
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment