wl-kbptr icon indicating copy to clipboard operation
wl-kbptr copied to clipboard

Non-zero exit code when user cancels selection

Open matejdro opened this issue 1 year ago • 2 comments

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')

matejdro avatar Jul 05 '24 16:07 matejdro

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.

moverest avatar Jul 05 '24 22:07 moverest

Thanks, test workaround works great! I was also not aware about Backspace, this will also come in handy.

matejdro avatar Jul 06 '24 05:07 matejdro

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

matejdro avatar May 14 '25 04:05 matejdro

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). 🤔

moverest avatar May 14 '25 12:05 moverest

Sorry my bad, I have messed up the script. Disregard that.

matejdro avatar May 14 '25 19:05 matejdro

No worries.

moverest avatar May 14 '25 20:05 moverest

Status code upon cancellation can now be set with the cancellation_status_code setting (35141120e097a9b54c7a1866abf0e3948db5650e).

moverest avatar May 15 '25 13:05 moverest

Can confirm it works great. Thanks!

matejdro avatar Aug 06 '25 10:08 matejdro