diff --git a/scripts/scrot-ocr.sh b/scripts/scrot-ocr.sh new file mode 100755 index 0000000..b90c6d3 --- /dev/null +++ b/scripts/scrot-ocr.sh @@ -0,0 +1,16 @@ +#!/bin/bash +scrot-ocr: Select screen region → OCR → clipboard +Deps: grim, slurp, tesseract, wl-clipboard, libnotify +set -euo pipefail + +LANG="${1:-eng}" +IMG="/tmp/scrot-ocr-$(date +%s).png" + +grim -g "$(slurp -d)" "$IMG" +TEXT=$(tesseract "$IMG" stdout -l "$LANG" 2>/dev/null | sed '/^[[:space:]]*$/d') + +echo -n "$TEXT" | wl-copy --paste-once +echo "$TEXT" + +notify-send "scrot-ocr" "$(echo "$TEXT" | wc -l) lines copied to clipboard" -t 3000 +rm -f "$IMG"