add script

This commit is contained in:
histausse 2021-10-27 23:08:39 +02:00
commit 8221e5a533
Signed by: histausse
GPG key ID: 67486F107F62E9E9
2 changed files with 28 additions and 0 deletions

12
README.md Normal file
View file

@ -0,0 +1,12 @@
# Screen to text
Take a screen shot, run OCR on it, and put the result to the clipboard
Dependencies:
- spectacle
- tesseract
- xclip (for X, wayland might need more configuration)
```
sudo pacman -S spectacle tesseract tesseract-data-fra tesseract-data-eng tesseract-data-osd xclip
```

16
screen_to_text.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# Take a screen shot, run OCR on it, and put the result to the clipboard
#
# Dependencies:
# - spectacle
# - tesseract
# - xclip (for X, wayland might need more configuration)
#
# `sudo pacman -S spectacle tesseract tesseract-data-fra tesseract-data-eng tesseract-data-osd xclip`
TESS_LANG='fra+eng+osd'
file='/tmp/img_'`head --bytes=20 /dev/urandom | md5sum | head --bytes=20`'.png'
/sbin/spectacle --region --background --nonotify --output "$file"
/sbin/tesseract "$file" - -l "$TESS_LANG" | /sbin/xclip -in -selection clipboard