moverest / wl-kbptr

Control the mouse pointer with the keyboard on Wayland.
GNU General Public License v3.0
43 stars 4 forks source link

Non-zero exit code when user cancels selection #13

Open matejdro opened 5 days ago

matejdro commented 5 days ago

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

moverest commented 5 days ago

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.

matejdro commented 4 days ago

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