Skip to content

Instantly share code, notes, and snippets.

@QazCetelic
Created April 24, 2023 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QazCetelic/6cae8ed89cfdfac8fe4f4adce03a8562 to your computer and use it in GitHub Desktop.
Save QazCetelic/6cae8ed89cfdfac8fe4f4adce03a8562 to your computer and use it in GitHub Desktop.
Script to copy text from screen bitmap.
#!/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