[PATCH] base-files: add blink and turnoff commands to the led script
Karl Palsson
karlp at tweak.net.au
Mon Jun 28 03:01:08 PDT 2021
John Crispin <john at 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. at system[-1].leds_off
> to 1.
You actually force them all off though, rather than "not load any
state" ? Is the intention for "leds_off" like the name, or the
intention to be "don't touch any leds" in which case the name and
implementation don't match the commit description?
Also, what's the use case for blink in the default install? It's
not pushing any stack for a temporary blink, it just hard sets
allllll led to blink. I can see plenty of uses for this in
private testing builds, I have something similar myself for
production testing that all leds function, but i'm having a hard
time seeing what the use case for it is in general, and why it
should be in the default build.
Sincerely,
Karl Palsson
>
> Signed-off-by: John Crispin <john at 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. at 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 at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP-digital-signature.html
Type: application/pgp-signature
Size: 1175 bytes
Desc: OpenPGP Digital Signature
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20210628/b9beccf0/attachment.sig>
More information about the openwrt-devel
mailing list