#wayland-clipboard #wayland #ocr #screenshot #hyprland #clipboard

bin+lib ocrgrab

Screenshot-to-clipboard OCR for Wayland — grab a region, get the text

5 releases

0.2.5 Aug 27, 2026
0.2.4 Aug 27, 2026
0.2.0 May 29, 2026
0.1.0 Apr 22, 2026
0.0.1 Apr 16, 2026

#1499 in Images

MIT license

185KB
4K SLoC

ocrgrab

Screenshot-to-clipboard OCR for Wayland (Hyprland): grab a region, get the text — with a viewer to select words, lines or blocks and copy them.

OCR runs locally by default: PaddleOCR models (PP-OCRv6 detector + PP-OCRv5 Latin recognizer, Portuguese/English incl. accents) on ONNX Runtime, in-process, no network, no account. Google Document AI is an optional second engine for the crops the local one gets wrong.

Install

cargo install ocrgrab      # needs grimblast + xdg-utils at runtime
ocrgrab setup              # checks tools, downloads the OCR models (~18 MB),
                           # optionally configures Google Document AI

Running without setup works too — the models are fetched on the first OCR.

Use

ocrgrab screenshot                 # select a region/window → OCR → viewer
                                   #   (Enter = grab the whole screen, Esc = cancel)
ocrgrab screenshot --no-view       # …print the text instead of opening the viewer
ocrgrab view image.png             # OCR a file and open the viewer
ocrgrab ocr image.png [--json]     # headless; --json prints the Document-AI-shaped result
ocrgrab replay image.png           # reopen the viewer from the cached result

In the viewer: click/drag to select, double-click a word, triple-click a line, click a block's border to copy it, Ctrl+C copy, Ctrl+A all, Ctrl+0 fit, scroll to zoom, right/middle-drag to pan when zoomed in (snaps back when the image already fits), Esc clear / exit.

Engines

local (default) documentai
Where in-process, CPU Google Cloud
Needs nothing (models auto-downloaded) project_id, processor_id, gcloud ADC
Select --engine local / config engine = "local" --engine documentai

With Document AI configured, Ctrl+G in the viewer re-runs the current image through Document AI when the local result isn't good enough. Results are cached per image and per engine under the cache directory.

Config

ocrgrab config path prints the file; ocrgrab config edit opens it. Keys: engine, models_dir, cache_dir, screenshots_dir, project_id, processor_id, location, credentials_path, viewer tuning (zoom_step, fit_padding, …).

Dependencies

~136MB
~2.5M SLoC