blob: de84d93483c4151d6f60e4acdaa46c871ef6011d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|