From 4ad564bd80dd5cbad82b8622996639a9360afd1d Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Sun, 5 Jul 2026 21:29:08 +0100 Subject: [PATCH] feat(capture): OCR region to clipboard (LATER item) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- agent/BACKLOG.md | 3 --- agent/HARDWARE-QUEUE.md | 5 +++++ agent/JOURNAL.md | 20 ++++++++++++++++++++ modules/home/rofi.nix | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/agent/BACKLOG.md b/agent/BACKLOG.md index 358b945..68ecaba 100644 --- a/agent/BACKLOG.md +++ b/agent/BACKLOG.md @@ -234,9 +234,6 @@ them as composable commands, not dead ends. - **Night-light geo mode**: lat/long auto sunset/sunrise (means wlsunset). - **Per-theme icon overrides** / more icon packs (ROADMAP § Icon themes). - **MIPI/IPU software-ISP camera** support (no-UVC machines). -- **OCR screenshot-to-text**: a Capture › entry (grim region → tesseract - → clipboard) — recording (#12, shipped 2026-07-04) already reshaped - the submenu, so this is now a two-row addition. - **Doctor Waybar warning**: a self-gating bar indicator fed by `nomarchy-doctor` (shipped 2026-07-04) — appears only when the sheet has a ✖; click opens the sheet. diff --git a/agent/HARDWARE-QUEUE.md b/agent/HARDWARE-QUEUE.md index 2a94cbb..2b81c6b 100644 --- a/agent/HARDWARE-QUEUE.md +++ b/agent/HARDWARE-QUEUE.md @@ -167,6 +167,11 @@ QA machine), the **T14s** (webcam case). (tooltips, fastfetch labels) is visible on summer-day + flexoki-light, kanagawa floats are lighter than the bg (upstream sumiInk4). Anything that reads worse than before → reopen 28b. +- [ ] **OCR region (LATER item)** — Tools › Capture › "OCR region → + clipboard": select a region with visible text → toast reports + the word count and `wl-paste` yields the text; Esc in slurp + cancels silently; a text-free region toasts "No text recognized" + without clobbering the clipboard. - [ ] **Look & Feel submenu (item 19)** — root menu: "Look & Feel" (replacing Theme, root still six rows) → Theme grid opens, Next wallpaper cycles instantly, Night light toggles (and is GONE diff --git a/agent/JOURNAL.md b/agent/JOURNAL.md index 8ee5f54..ead5369 100644 --- a/agent/JOURNAL.md +++ b/agent/JOURNAL.md @@ -17,6 +17,26 @@ Template: --- +## 2026-07-05 — OCR screenshot-to-text (iteration #41, LATER item) +- **Task:** LATER › OCR (NEXT is fully human/event-gated, so LATER is + in play per LOOP.md). Bullet deleted. +- **Did:** Capture › "OCR region → clipboard" (self-gated on + tesseract): slurp (Esc = silent cancel, the recording pattern) → + grim → tesseract stdin/stdout → wl-copy, whitespace-only results + toast instead of clobbering the clipboard; success toasts the word + count. tesseract ships eng-only via rofi.nix home.packages + (override documented — unscoped it drags every language's + traineddata, real cost on a compile-from-source distro). +- **Verified:** V0; V1 — template-home builds, menu bash -n, gated + row + case present; FUNCTIONAL — the profile's own tesseract read a + rendered test image back verbatim ("Nomarchy OCR smoke test 42"), + so the OCR half of the pipe is proven; grim/slurp half needs a + session → V3 queued. +- **Pending:** V3. +- **Next suggestion:** LATER: doctor Waybar warning (self-gating bar + indicator fed by nomarchy-doctor) or auto-timezone tooltip; both + small. + ## 2026-07-05 — Look & Feel menu category (iteration #40, item 19) - **Task:** BACKLOG NEXT#19 — its ≥3-entries gate is met (Theme, Next wallpaper, Night light). Item deleted. diff --git a/modules/home/rofi.nix b/modules/home/rofi.nix index 2514b2c..e00bd60 100644 --- a/modules/home/rofi.nix +++ b/modules/home/rofi.nix @@ -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