Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a debug msg to distinguish cancellation by ESC and click #127

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cjacker
Copy link

@cjacker cjacker commented Apr 7, 2023

As mentioned in #126, I bind a script to 'Print' key and intend to use 'ESC' to cancel and 'click' to take a whole screenshot.

Currently, both ESC and click print out same msg 'selection cancelled', and I need a different msg to distinguish cancellation by ESC from click.

The previous try in #126 is stupid. What I need is just a different msg, one more fprintf is enough for that.

The script I use:

#!/usr/bin/bash

IMG_VIEWER=pqiv

FILENAME=screenshot-$(LANG=C LC_ALL=C date "+%Y-%m-%d-%H-%M-%S").png

SELECT=$(LANG=en_US slurp 2>&1)

if [ "$SELECT""x" == "ESC pressed selection cancelled""x" ]; then
  true
elif [ "$SELECT""x" == "selection cancelled""x" ]; then
  grim "$HOME"/"$FILENAME" && $IMG_VIEWER "$HOME"/"$FILENAME"
else
  grim -g "$SELECT" "$HOME"/"$FILENAME" && $IMG_VIEWER "$HOME"/"$FILENAME"
fi

@emersion
Copy link
Owner

emersion commented Apr 7, 2023

Error messages should not be relied upon. They might change, be localized, etc. They are for human consumption only.

@cjacker
Copy link
Author

cjacker commented Apr 8, 2023

Error messages should not be relied upon. They might change, be localized, etc. They are for human consumption only.

I am not sure which is your prefer way, and took a look at hacksaw, 'click' print 'global cursor pos 0x0' and 'ESC' report a cancellation msg, it can be used to:

  • distinguish 'click' from 'ESC'.
  • take a screenshot of window at global cursor pos if screenshot utility support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants