feat(capture): OCR region to clipboard (LATER item)
All checks were successful
Check / eval (push) Successful in 3m6s
All checks were successful
Check / eval (push) Successful in 3m6s
Tools › Capture gains "OCR region → clipboard", self-gated on tesseract: slurp the region (Esc cancels silently, the recording.nix pattern), grim it, tesseract stdin→stdout, wl-copy. Whitespace-only recognition toasts "No text recognized" instead of clobbering the clipboard; success toasts the word count. tesseract ships English-only through the menu's package set — the unscoped wrapper pulls every language's traineddata, a real cost on a compile-from-source distro; overriding with more languages is documented at the package line. Verified: V0; V1 — template-home builds with the gated row + case and menu bash -n; functional — the profile's own tesseract read a rendered test image back verbatim, proving the OCR half of the pipe. The grim/slurp half needs a session → HARDWARE-QUEUE. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -370,6 +370,7 @@ ${themeRows}
|
||||
row "Region → file" applets-screenshooter
|
||||
row "Full screen → clipboard" camera-photo
|
||||
row "Full screen → file" camera-photo
|
||||
command -v tesseract >/dev/null 2>&1 && row "OCR region → clipboard" scanner
|
||||
if command -v nomarchy-record >/dev/null 2>&1; then
|
||||
if nomarchy-record active; then
|
||||
row "■ Stop recording" media-playback-stop
|
||||
@@ -389,6 +390,16 @@ ${themeRows}
|
||||
*"Region → clipboard"*) grim -g "$(slurp)" - | wl-copy ;;
|
||||
*"Region → file"*) mkdir -p "$dir"; grim -g "$(slurp)" "$file" \
|
||||
&& notify-send "Screenshot saved" "$file" ;;
|
||||
*"OCR region"*)
|
||||
# Select → screenshot → tesseract → clipboard. Esc in slurp
|
||||
# cancels silently (the recording.nix pattern); recognizing
|
||||
# nothing toasts instead of copying an empty clipboard.
|
||||
geo=$(slurp) || exit 0
|
||||
txt=$(grim -g "$geo" - | tesseract stdin stdout 2>/dev/null)
|
||||
[ -n "''${txt//[[:space:]]/}" ] \
|
||||
|| { notify-send "OCR" "No text recognized in that region."; exit 0; }
|
||||
printf '%s' "$txt" | wl-copy
|
||||
notify-send "OCR" "Copied $(printf '%s' "$txt" | wc -w) word(s) to the clipboard." ;;
|
||||
*"Full screen → clipboard"*) grim - | wl-copy ;;
|
||||
*"Full screen → file"*) mkdir -p "$dir"; grim "$file" \
|
||||
&& notify-send "Screenshot saved" "$file" ;;
|
||||
@@ -796,6 +807,10 @@ in
|
||||
pkgs.nodejs # npx, for the Ask Claude module (claude-code from npm)
|
||||
pkgs.networkmanager_dmenu # network module: rofi wifi/VPN picker
|
||||
pkgs.rofi-pulse-select # audio module: sink/source switcher
|
||||
# Capture › OCR region: English only — the unscoped wrapper drags
|
||||
# in every language's traineddata, a real cost on a compile-from-
|
||||
# source distro. More languages: override in your home.nix.
|
||||
(pkgs.tesseract.override { enableLanguages = [ "eng" ]; })
|
||||
];
|
||||
|
||||
# networkmanager_dmenu drives rofi (not bare dmenu) and uses rofi's
|
||||
|
||||
Reference in New Issue
Block a user