Hummer12007 / brightnessctl

A program to read and control device brightness
Other
900 stars 48 forks source link

Possible bug when decreasing brightness level #66

Closed ZOulhadj closed 3 years ago

ZOulhadj commented 3 years ago

I am using Sway + Waybar and I have setup my brightness key bindings as follows:

bindsym XF86MonBrightnessDown exec "brightnessctl set 5%-" bindsym XF86MonBrightnessUp exec "brightnessctl set +5%"

The issue is when starting at a brightness level of 0% and going up it increases by 5% as expected. However, when going from 100% down, it initially goes down to 94% which not is not right as that it a decreased of 6%. What is weird is that after the first decrease it goes returns to normal decreasing by 5%.

So 100%, 94%??, 89% and so on....

trygveaa commented 3 years ago

This is an issue with waybar, not brightnessctl as far as I can see. On my machine the max brightness is 19393. 5% of that is 969.65, and when the backlight is on max brightness and I reduce it by 5% with brightnessctl, it rounds 969.65 to 970 (since it can't set fractions) and sets it to 18423. 18423 divided by 19393 is 0.94998195225081214871, which apparently waybar shows at 94%.

So the issue is that waybar truncates/rounds down the percentage fraction, instead of rounding it to the nearest whole number.

ZOulhadj commented 3 years ago

Can confirm that I see this issue with other programs such as PulseAudio. Does seem to look like a Waybar issue. I will open an issue with them. Thank you for confirming.