Non-zero exit code when user cancels selection
Could the application return non-zero exit code when not performing any mouse moving (exiting via ESC)?
In most cases, when I press ESC I usually made a mistake (mistyped and went into wrong cell), so I would want to cancel the entire operation when pressing ESC. If application returns non-zero exit code, this can be simply achieved by using && to chain to switching to fine mouse movement (bindsym Shift+a mode default, exec 'wl-kbptr && swaymsg mode Mouse')
At the moment, you can detect a cancellation as it will not print the selected area and requested click in the standard output. This means that something like test -n "$(wl-kbptr)" should return a non-zero status if the user cancels.
Now, this could also indicated through a status code as you are suggesting. I'm not sure if it would be best to add this as an option — e.g. something like --error-status-on-cancel — or do this systematically though. It seems like a sensible feature anyway. :thinking:
In most cases, when I press ESC I usually made a mistake (mistyped and went into wrong cell), so I would want to cancel the entire operation when pressing ESC.
Note that if you mistype, you can always correct your input with a Backspace key press and it can go back all the way to the initial area. Granted that feature is not documented in the README.
Thanks, test workaround works great! I was also not aware about Backspace, this will also come in handy.
OpenCV mode prints a bunch of ok statements into output, regardless of the selection. So, to make this workaround work, wl-kbptr has to now be piped into | grep -v ok
That's weird. I don't see any print statement in the code so it probably comes from OpenCV itself. I can't reproduce on my machine either (Arch Linux x86_64, wl-kbptr 0.3.0 or 92d815ec89b23f2b13dd17725f109abd80e24606, opencv 4.11.0-9). 🤔
Sorry my bad, I have messed up the script. Disregard that.
No worries.
Status code upon cancellation can now be set with the cancellation_status_code setting (35141120e097a9b54c7a1866abf0e3948db5650e).
Can confirm it works great. Thanks!