francma / wob

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

Should wob really exit due to invalid input? #22

Closed primeos closed 3 years ago

primeos commented 4 years ago

I don't have a strong opinion on this but I was wondering if it wouldn't be better to just ignore invalid input (and print a warning to stderr or show some graphical indication of a failure, e.g. a red overlay bar or error message).

An advantage of the current behaviour (exiting) is that errors in scripts etc. become more apparent, but it might also be annoying when testing scripts as one would possibly need to restart wob quite often. Or if users aren't aware of this behaviour and don't see the output (e.g. when started via sway's exec) they might think that it did crash for another reason.

If there where some graphical indication that invalid input was received this might be better / more comfortable. Or one could introduce a flag to let the user choose the behaviour.

bwiercinski commented 4 years ago

I would also rethink behaviour for inputs out of range [0;100]. It is not something unimaginable that I want to set my volume to 150%... Ultimate solution would be displaying the bar as if it were set to 100% with the text in the middle 150. Displaying text is also handy for values below 100.

Of course all of these would be set via flags so I'm proposing:

Temporary solution

some_command | grep -P '^([0-9]{1,2}|100)$' > /path/to/wob.fifo
francma commented 4 years ago

You can set maximum value via -m flag to allow values above 100. I think there is always some kind of maximum value - sound/brightness doesn't go up to +inf. I have not come across situation where it wasn't possible to feed wob only valid values. Maybe you provide some examples where this might happen.

One thing I want to add is to print input that caused wob to exit. With startup command like this, it should give you some hints about what went wrong.

exec mkfifo $SWAYSOCK.wob && tail -f $SWAYSOCK.wob | wob 2> ~/.wob.log
NilsIrl commented 4 years ago

Temporary solution

some_command | grep -P '^([0-9]{1,2}|100)$' > /path/to/wob.fifo

My solution is this: $(($volume > 100 ? 100 : $volume))

francma commented 3 years ago

Implemented in #67