Files
arthur-os/bin/omarchy-capture-text-extraction
T
75eec08758 Add screenshot OCR functionality with Minimal Dependencies (#1918)
* Add script to capture screenshot, perform OCR, and copy text to clipboard

* Add binding for screenshot-ocr

* Update OCR binding description

* Add tesseract OCR and language data installation

* Update bindings to current dev

* Refactor screenshot capture method to use wayfreeze and slurp for region selection

* Refactor OCR text extraction to simplify error handling

* Bring up to date

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
2026-05-03 15:25:33 +02:00

27 lines
750 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Extract text from a screenshot region with OCR
# omarchy:group=capture
# omarchy:examples=omarchy capture ocr
# Keep hyprpicker alive until after grim captures so the screenshot sees the
# frozen overlay rather than live content shifting during teardown.
cleanup_freeze() {
[[ -n $PID ]] && kill $PID 2>/dev/null
}
trap cleanup_freeze EXIT
hyprpicker -r -z >/dev/null 2>&1 &
PID=$!
sleep .1
SELECTION=$(slurp 2>/dev/null)
[[ -z $SELECTION ]] && exit 0
TEXT=$(grim -g "$SELECTION" - | tesseract stdin stdout --oem 1 --psm 6 -l eng --dpi 300 -c preserve_interword_spaces=1 2>/dev/null) || exit 1
[[ -z $TEXT ]] && exit 1
printf "%s" "$TEXT" | wl-copy
notify-send "󰴑 Copied text from selection to clipboard"