From f56cce2e20ac5f31981b5a0adb606f277ddb675b Mon Sep 17 00:00:00 2001 From: clsr Date: Fri, 19 Jun 2020 22:56:19 +0200 Subject: Add raw_min special case for nvidia backlight --- bl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bl b/bl index 84f14d7..7db821e 100755 --- a/bl +++ b/bl @@ -27,6 +27,7 @@ get_bldir() { exit 1 fi bldir="$f" + BACKLIGHT="${f##*/}" done fi } @@ -60,6 +61,12 @@ get_brightness() { raw_curr="$(read_num "$bldir/brightness")" max=100 curr=$(( (raw_curr + (raw_max / 2 / max)) * max / raw_max )) + + # brightness 0 tends to completely turn off the backlight + raw_min=1 + case "$BACKLIGHT" in + nvidia_[0-9]*) raw_min=0 ;; # nvidia_0 at 0 is still not off + esac } get_raw_new() { @@ -92,9 +99,8 @@ get_raw_new() { if [ "$raw_new" -gt "$raw_max" ]; then raw_new="$raw_max" fi - if [ "$raw_new" -le 0 ]; then - # brightness 0 tends to completely turn off the backlight - raw_new=1 + if [ "$raw_new" -lt "$raw_min" ]; then + raw_new="$raw_min" fi fi } -- cgit