From b1d425536cfe448a599e0183fdad8d0b13897019 Mon Sep 17 00:00:00 2001 From: Xiao Pan Date: Mon, 23 Mar 2026 06:36:45 +0800 Subject: fix: backlight consider bright not multiple of step backlight consider after long time no use, screen go black then me wake it and go bright, the brightness is not a multiple of step, so it can not decrease to 1 or 0 or increase to max Also consider no write if decrease when 0 or increase when max --- sh/backlight | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sh/backlight') diff --git a/sh/backlight b/sh/backlight index 3de87f5..b9fdbfb 100755 --- a/sh/backlight +++ b/sh/backlight @@ -9,14 +9,28 @@ case "$1" in case "$brightness" in 0) echo 1;; 1) echo "$step";; - *) echo "$((brightness+step))";; + "$max_brightness") exit 0;; + *) + if [ "$brightness" -gt "$((max_brightness-step))" ]; then + echo "$max_brightness" + else + echo "$((brightness+step))" + fi + ;; esac ;; '-d') case "$brightness" in + 0) exit 0;; 1) echo 0;; "$step") echo 1;; - *) echo "$((brightness-step))";; + *) + if [ "$brightness" -le "$step" ]; then + echo 1 + else + echo "$((brightness-step))" + fi + ;; esac ;; *) exit 1;; -- cgit v1.3