ACK I like this. Good for many applications, not the least of which include a quick "stealth mode" LED setting or warning/notification LED blink patterns.
All the best, Nick On Mon, 28 Jun 2021 at 17:18, John Crispin <j...@phrozen.org> wrote: > > This allows us to make all leds blink or force all leds to off. > It is also possible to force the default behaviour to not load > any led states/triggers by setting system.@system[-1].leds_off > to 1. > > Signed-off-by: John Crispin <j...@phrozen.org> > --- > package/base-files/files/etc/init.d/led | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/package/base-files/files/etc/init.d/led > b/package/base-files/files/etc/init.d/led > index 51cb8b5178..252bba623a 100755 > --- a/package/base-files/files/etc/init.d/led > +++ b/package/base-files/files/etc/init.d/led > @@ -3,6 +3,9 @@ > > START=96 > > +extra_command "turnoff" "Turn all leds off" > +extra_command "blink" "Blink all leds" > + > load_led() { > local name > local sysfs > @@ -121,7 +124,25 @@ load_led() { > } > } > > +turnoff() { > + for led in `ls /sys/class/leds/`; do > + echo none > /sys/class/leds/$led/trigger > + echo 0 > /sys/class/leds/$led/brightness > + done > +} > + > +blink() { > + for led in `ls /sys/class/leds/`; do > + echo 0 > /sys/class/leds/$led/brightness > + echo timer > /sys/class/leds/$led/trigger > + done > +} > + > start() { > + [ "$(uci get system.@system[-1].leds_off)" -eq 1 ] && { > + turnoff > + exit 0 > + } > [ -e /sys/class/leds/ ] && { > [ -s /var/run/led.state ] && { > local led trigger brightness > @@ -137,5 +158,7 @@ start() { > > config_load system > config_foreach load_led led > + . /etc/diag.sh > + set_state done > } > } > -- > 2.25.1 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel