Based off of this script (the 2nd one) I whittled the script down to this:
#!/bin/bash
# Dependencies: tesseract-ocr imagemagick gnome-screenshot xclip
SCR="/home/takingitcasual/Documents/Translate/temp"
gnome-screenshot -a -f $SCR.png
mogrify -modulate 100,0 -resize 400% $SCR.png
#should increase detection rate
tesseract $SCR.png $SCR -psm 10 -l jpn
cat $SCR.txt | xclip -selection clipboard
#you can only scan one character at a time
exit
Some goals I had with the modified file:
- Removing the need for sudo (to allow for easy hotkey binding)
- Replacing scrot (the way gnome-screenshot works looks much nicer IMO)
- Simplify the script to something I can more easily understand (removal of temp files)
- Limit recognition to one character at a time. (recognition was abysmal without that "-psm 10", and Tesseract kept throwing "empty page" errors as well)
Another two things I did were:
chmod a+x /home/takingitcasual/Documents/Translate/
and setting the temp files permissions to read/write for all. Not sure if it was redundant to do both.
Last thing was giving the bash command
bash /home/takingitcasual/Documents/Translate/screen_ts.sh
a shortcut via this.
If anybody has suggestions on modifying the script or anything else I'd love to hear it. (I have no previous experience with scripting, so I'm sure it can be improved.)