Created
April 24, 2023 15:43
-
-
Save QazCetelic/6cae8ed89cfdfac8fe4f4adce03a8562 to your computer and use it in GitHub Desktop.
Script to copy text from screen bitmap.
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
#!/bin/sh | |
# Written by u/QazCetelic licensed under GPL3 | |
if ! which spectacle > /dev/null; then | |
kdialog --sorry "spectacle, the required screenshotting tool, is not installed." | |
exit 1 | |
fi | |
if ! which tesseract > /dev/null; then | |
kdialog --sorry "tesseract, the required OCR package, is not installed." | |
exit 1 | |
fi | |
screenshot_tempfile=$(mktemp) | |
spectacle -brn -o $screenshot_tempfile | |
text_tempfile=$(mktemp) | |
tesseract $screenshot_tempfile $text_tempfile | |
rm $screenshot_tempfile | |
result_text=$(cat $text_tempfile.txt) | |
rm $text_tempfile.txt | |
echo $result_text | xclip -selection clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment