summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2020-06-19 22:56:19 +0200
committerclsr <clsr@clsr.net>2020-06-19 22:56:19 +0200
commitf56cce2e20ac5f31981b5a0adb606f277ddb675b (patch)
treec63bf22e3d3bfea1bea6cf22f3857a41618a48ba
parentd8fdc47628e4fda11c18a704b075b9a9cdc4cb95 (diff)
downloadbl-f56cce2e20ac5f31981b5a0adb606f277ddb675b.tar.gz
bl-f56cce2e20ac5f31981b5a0adb606f277ddb675b.zip
Add raw_min special case for nvidia backlight
-rwxr-xr-xbl12
1 files 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
}