From cbdfd03e42f5619127d357eaba48b77f62628654 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Owoc?= Date: Fri, 6 Dec 2024 17:11:59 +0100 Subject: [PATCH] base-files: add option to set LED brightness MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add option to set LED brightness via uci: config led 'led_blue' option name 'blue' option sysfs 'blue:status' option brightness '1' Signed-off-by: Paweł Owoc Link: https://github.com/openwrt/openwrt/pull/17190 Signed-off-by: John Crispin --- package/base-files/files/etc/init.d/led | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led index 377b9dcf3e..d292e2a8dd 100755 --- a/package/base-files/files/etc/init.d/led +++ b/package/base-files/files/etc/init.d/led @@ -51,6 +51,7 @@ load_led() { local delayon local delayoff local interval + local brightness config_get sysfs $1 sysfs config_get name $1 name "$sysfs" @@ -67,6 +68,7 @@ load_led() { config_get message $1 message "" config_get gpio $1 gpio "0" config_get_bool inverted $1 inverted "0" + config_get brightness $1 brightness [ "$2" ] && [ "$sysfs" != "$2" ] && return @@ -105,7 +107,8 @@ load_led() { echo 0 >/sys/class/leds/${sysfs}/brightness [ $default = 1 ] && - cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness + [ -z "$brightness" ] && brightness=$(cat /sys/class/leds/${sysfs}/max_brightness) + echo $brightness > /sys/class/leds/${sysfs}/brightness led_color_set "$1" "$sysfs" -- 2.30.2