clipboard

Sometimes I need to snip text that can't be copy pasted. For this, I use tesseract, which depends on tessdata for language support. See Gentoo Wiki: Localization ⇗.

/etc/portage/package.use/tesseract
app-text/tesseract jpeg tiff webp png float32
media-libs/leptonica tiff png webp jpeg       # deps
app-text/tessdata_fast L10N: ja en zh         # lang

Reminder: How do we snip on Linux in general?

Since I use Hyprland, snipping is more manual, typically involving

  1. gui-apps/slurp  - geometry selector
  2. gui-apps/grim   - screenshot tool
  3. gui-apps/swappy - screenshot editor
grim -g "$(slurp)" | swappy -f -

Adding image recognition by tesseract is a similar set of steps.

  1. gui-apps/slurp        - geometry selector
  2. app-text/tesseract    - OCR optical character recognition
  3. gui-apps/wl-clipboard - clipboard for the Wayland display protocol
grim -g "$(slurp)" - \
  | tesseract stdin stdout -l eng+jpn \
  | wl-copy

Of course, if you haven't already, also install app-misc/cliphist for clipboard history.