Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions bin/omarchy-capture-text-extraction
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# 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
}
Expand All @@ -14,11 +15,24 @@ trap cleanup_freeze EXIT
hyprpicker -r -z >/dev/null 2>&1 &
PID=$!
sleep .1
SELECTION=$(slurp 2>/dev/null)

SELECTION=$(slurp 2>/dev/null)
[[ -z $SELECTION ]] && exit 0

TEXT=$(grim -g "$SELECTION" - | tesseract stdin stdout --oem 1 --psm 6 -l "${OMARCHY_OCR_LANGS:-eng}" --dpi 300 -c preserve_interword_spaces=1 2>/dev/null) || exit 1
LANGS=$(tesseract --list-langs 2>/dev/null | tail -n +2 | paste -sd+ -)

[[ -z "$LANGS" ]] && LANGS="eng"

TEXT=$(
grim -g "$SELECTION" - | \
tesseract stdin stdout \
--oem 1 \
--psm 6 \
--dpi 300 \
-l "$LANGS" \
-c preserve_interword_spaces=1 \
2>/dev/null
) || exit 1

[[ -z $TEXT ]] && exit 1

Expand Down