From 0e968b9cb19cb06b0fbe927ed8c2697fccb51f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grondek?= Date: Thu, 13 Feb 2020 13:18:32 +0100 Subject: [PATCH] [i3blocks] Limit brightness to (0,100)% --- i3/i3blocks/blocks/brightness | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/i3/i3blocks/blocks/brightness b/i3/i3blocks/blocks/brightness index 228b517..47efe27 100755 --- a/i3/i3blocks/blocks/brightness +++ b/i3/i3blocks/blocks/brightness @@ -8,8 +8,14 @@ get_brighntess() { } set_brightness() { - xrandr --output $output --brightness $(echo $1 | awk '{printf "%0.2f", $1/100}' ) brightness=$1 + if [ "$brightness" -gt 100 ]; then + brightness=100 + fi + if [ "$brightness" -lt 0 ]; then + brightness=0 + fi + xrandr --output $output --brightness $(echo $brightness | awk '{printf "%0.2f", $1/100}' ) } get_brighntess