wob icon indicating copy to clipboard operation
wob copied to clipboard

[feature req] Accept more inputs?

Open ComedyTomedy opened this issue 2 years ago • 3 comments

It would be good to accept more input without crashing, and make it slightly simpler to script with wob. I'd suggest:

  • integers continue as normal
  • allow the string "%" at the end of the number, so 0%-100%.
  • accept empty input as if it were 0, so echo | wob would work, (and commands with empty output, too)
  • perhaps accept any other non-empty string as if it were "100". Along with empty-input being zero, this would allow grep | wob without needing sed etc.

The downside of adding these behaviours is that it would be difficult or impossible to add other valid input types in the future, at least without ambiguity. Although I don't think that would be very useful, unless you wanted to accept config changes or commands.

Separate/related thought - Exiting on invalid input isn't particularly helpful anyway, I think I'd prefer that it responds as best it can and keeps running.

ComedyTomedy avatar Sep 03 '23 16:09 ComedyTomedy

Why is it a problem that wob exits on invalid input? My use-case is that I first try if the script piping into wob works and then include it in service manager / sway config / whatever. And once the script works, it shouldn't really randomly break.

francma avatar Sep 03 '23 20:09 francma

This is true! My main idea is to make scripting easier, e.g. in sway/config. It's helped me make some toggles neater, because now a grep can replace [...] && ... || ....

As for the inputs, current wob is fragile but always correct, my proposed wob is robust but might silently coerce bad input. As you say it will only make a difference if underlying tools change, anyway.

I've made a wrapper script that implements this, for my own use. Just thought it might be useful to others :)

It's just an idea, if you're happy with current wob, so am I -- you've made something really useful 😊 thank you!

ComedyTomedy avatar Sep 03 '23 23:09 ComedyTomedy

I would also really prefer wob to not exit on invalid input.

Although I do test my scripts it (surprisingly) sometime happens that I miss something and then wob is killed for the session, forcing to either start it manually or restart the whole session for further debugging.

Finally, I don't see how wob exiting is a useful feature in itself, but maybe I am missing some use case

Lcchy avatar Dec 22 '23 14:12 Lcchy