From c4b2f0adeaa862c176a3ea14925b0caa6ea9f420 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Wed, 15 Nov 2023 00:25:36 -0800 Subject: [PATCH] Make wayland-screenshot.sh support japanese --- wayland-screenshot.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/wayland-screenshot.sh b/wayland-screenshot.sh index 4da4a93..005c88e 100755 --- a/wayland-screenshot.sh +++ b/wayland-screenshot.sh @@ -4,12 +4,24 @@ local resp="$(fuzzel --index -d <<'EOF' Whole screen Current window Selected area -Copy text with OCR +Copy text with OCR (English) +Copy text with OCR (Japanese) EOF )" local outfile="$(date +'screenshot-%F--%H-%M-%S.png')" +# copy_with_ocr +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 0) grim "${outfile}" @@ -27,11 +39,9 @@ case "${resp}" in grim -g "${area}" "${outfile}" ;; 3) - local area="$(slurp 2>&1)" - if [[ "${area}" != 'selection cancelled' ]]; then - local text="$(grim -g "${area}" -t png /dev/fd/1 | - tesseract stdin stdout -l eng 2>/dev/null)" - wl-copy "${text}" - notify-send -t 5000 "Coppied Text" "Coppied ${#text} characters" - fi + copy_with_ocr eng + ;; + 4) + copy_with_ocr jpn + ;; esac