From f6aedd07d52e1bfa83378c6b4d303f211cbd764d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grondek?= Date: Thu, 7 Nov 2019 10:41:13 +0100 Subject: [PATCH] [i3] Fix brightness block --- i3/i3blocks/blocks/brightness | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/i3/i3blocks/blocks/brightness b/i3/i3blocks/blocks/brightness index 5a5836c..c131479 100755 --- a/i3/i3blocks/blocks/brightness +++ b/i3/i3blocks/blocks/brightness @@ -1,14 +1,23 @@ #!/usr/bin/env bash output=eDP-1 -brightness=$(xrandr --verbose | grep Brightness | awk '{printf "%d", $2*100}') +brightness=? -echo $brightness +get_brighntess() { + brightness=$(xrandr --verbose | grep Brightness | awk '{printf "%d", $2*100}') +} + +print_bringtness() { + get_brighntess + echo $brightness +} set_brightness() { xrandr --output $output --brightness $(echo $1 | awk '{printf "%0.2f", $1/100}' ) } +get_brighntess + case $BLOCK_BUTTON in 4) set_brightness $((brightness + 10 )) ;; # scroll up @@ -16,3 +25,5 @@ case $BLOCK_BUTTON in 5) set_brightness $((brightness - 10 )) ;; # scroll down esac + +print_bringtness