Make wayland-screenshot.sh support japanese

This commit is contained in:
Alexander Rosenberg 2023-11-15 00:25:36 -08:00
parent 1a88360489
commit c4b2f0adea
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -4,12 +4,24 @@ local resp="$(fuzzel --index -d <<'EOF'
Whole screen Whole screen
Current window Current window
Selected area Selected area
Copy text with OCR Copy text with OCR (English)
Copy text with OCR (Japanese)
EOF EOF
)" )"
local outfile="$(date +'screenshot-%F--%H-%M-%S.png')" local outfile="$(date +'screenshot-%F--%H-%M-%S.png')"
# copy_with_ocr <language>
function copy_with_ocr() {
local area="$(slurp 2>&1)"
if [[ "${area}" != 'selection cancelled' ]]; then
local text="$(grim -g "${area}" -t png /dev/fd/1 |
tesseract stdin stdout -l ${1} 2>/dev/null)"
wl-copy "${text}"
notify-send -t 5000 "Coppied Text" "Coppied ${#text} characters"
fi
}
case "${resp}" in case "${resp}" in
0) 0)
grim "${outfile}" grim "${outfile}"
@ -27,11 +39,9 @@ case "${resp}" in
grim -g "${area}" "${outfile}" grim -g "${area}" "${outfile}"
;; ;;
3) 3)
local area="$(slurp 2>&1)" copy_with_ocr eng
if [[ "${area}" != 'selection cancelled' ]]; then ;;
local text="$(grim -g "${area}" -t png /dev/fd/1 | 4)
tesseract stdin stdout -l eng 2>/dev/null)" copy_with_ocr jpn
wl-copy "${text}" ;;
notify-send -t 5000 "Coppied Text" "Coppied ${#text} characters"
fi
esac esac