From fbb95d86079a624309306acf93e6cbee226ffbdd Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Fri, 8 Dec 2023 12:37:11 -0500 Subject: Add screenshot_ocr.sh --- local/bin/screenshot_ocr.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 local/bin/screenshot_ocr.sh (limited to 'local/bin/screenshot_ocr.sh') diff --git a/local/bin/screenshot_ocr.sh b/local/bin/screenshot_ocr.sh new file mode 100755 index 0000000..de84d93 --- /dev/null +++ b/local/bin/screenshot_ocr.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Select a region of the screen and perform OCR to it. Save text in clipboard. + +savepath="/tmp/screenshot_ocr.sh.d" +filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png" +tesseract_options="-l eng" + +_init() { + if [ ! -d "$savepath" ]; then + mkdir -p "$savepath" + fi + cd /tmp/screenshot_ocr.sh.d +} + +_init +# screenshot region of screen +shotgun -g $(hacksaw) "$filename" +# exit if previous command was unsuccessful +test $? -ne 0 && exit +# perform OCR and save to clipboard +tesseract $tesseract_options $filename - | xclip -selection "clipboard" +rm $filename -- cgit v1.2.3