summaryrefslogtreecommitdiff
path: root/sh/backlight
diff options
context:
space:
mode:
authorXiao Pan <xyz@flylightning.xyz>2026-03-23 06:36:45 +0800
committerXiao Pan <xyz@flylightning.xyz>2026-03-23 06:42:55 +0800
commitb1d425536cfe448a599e0183fdad8d0b13897019 (patch)
treef1577568bbd69b38d03ba765f3b58eb489b1524f /sh/backlight
parentb235ac4cf3b5b221e8604b983d39ac701446f868 (diff)
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
Diffstat (limited to 'sh/backlight')
-rwxr-xr-xsh/backlight18
1 files changed, 16 insertions, 2 deletions
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;;