29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
|
#!/usr/bin/bash
|
||
|
|
||
|
# Delay between running the command and flameshot launching
|
||
|
DELAY=$1
|
||
|
|
||
|
# Make the temp directory if it doesn't already exist
|
||
|
mkdir -p /tmp/jptesseract;
|
||
|
|
||
|
# flameshot is currently unable to only send output to stdout
|
||
|
# If we use flameshot gui --raw, we will send output to stdout and
|
||
|
# attempt to write a .png file. We **do not** want this .png file, since we can't
|
||
|
# easily predict the file name. Omitting --path causes a file explorer dialog to appear
|
||
|
# upon save. Writing to /dev/null is not allowed either, so our only option is to write them
|
||
|
# to somewhere we don't care about.
|
||
|
|
||
|
mkdir -p /tmp/jptesseract/.useless;
|
||
|
|
||
|
# Make sure we're in the right $PWD
|
||
|
cd /tmp/jptesseract || exit;
|
||
|
|
||
|
# Screenshot with flameshot, save to /tmp directory
|
||
|
if flameshot gui -d "$DELAY" -r --path /tmp/jptesseract/.useless > /tmp/jptesseract/jp_text_image.png; then
|
||
|
# Read from /tmp directory with Tesseract
|
||
|
tesseract -l jpn /tmp/jptesseract/jp_text_image.png /tmp/jptesseract/jp_output
|
||
|
|
||
|
# Take output and send it to the clipboard
|
||
|
xclip -selection clipboard < /tmp/jptesseract/jp_output.txt;
|
||
|
fi
|