francma / wob

A lightweight overlay volume/backlight/progress/anything bar for Wayland.
ISC License
907 stars 50 forks source link

Negative numbers support? #135

Open Lcchy opened 10 months ago

Lcchy commented 10 months ago

Hi there, thanks a lot for this neat utility, I use it every day on my work computer.

In certain scripts I make use of negative numbers to indicate a further decrease in the output value. Wob indicates them in red which fits this use case nicely.

Nevertheless, it seems that negative numbers are somehow offset? -1 displays a nearly empty bar and decreasing the input decreases the bar until -17 suddenly wraps around and displays a nearly full red bar (with -16 being an empty bar). Decreasing the numbers further reduces the red bar intuitively but with and offset of 16.

I therefore wanted to ask, are negative numbers officially supported by wob? And if so, is this behavior known or might there be a bug hiding?

Thanks for the help.

EDIT: I have just seen that input is assigned to an unsigned long: (https://github.com/francma/wob/blob/729e5c68215547eb8939c4c1778f58cca36b2bc0/src/wob.c#L367) So -1 just overflows and wraps around, wob handling it as (2^64 - 1) % 100 = 15 hence the offset I've observed. For now I've just offset my script output as a workaround but I think it would be nice to have official negative numbers support, would you be open to it @francma ?