Created
July 5, 2017 15:27
-
-
Save shello/3d3ba62ab1e02ee8cfad0e14ad54444b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Interactively capture a screenshot (using the cursor), and decode any 1D or 2D | |
# barcodes in the image (such as QR Code, EAN-13, etc...) | |
# | |
# OS X / macOS only | |
# Requires: | |
# - zbar (http://zbar.sourceforge.net/, `brew install zbar`) | |
# - screencapture (included with the system) | |
function screenqr() { | |
for cmd in zbarimg screencapture; do | |
type "$cmd" >/dev/null 2&>1 || { | |
echo "$0: '$cmd' is required but could not be found. Exiting." >&2 | |
return 1 | |
} | |
done | |
tmpfile=$(mktemp) | |
screencapture -i "$tmpfile" && zbarimg --quiet "$tmpfile" | |
rm "$tmpfile" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment