Couldn’t find an OCR tool I liked on Hyprland, so I wrote one.
You need four pieces: Tesseract (OCR engine), Grim (Wayland screenshots), Slurp (region selection), and wl-clipboard (clipboard).
sudo pacman -S tesseract grim slurp wl-clipboard
Three steps: Slurp selects a region for Grim to capture, Tesseract reads it, result goes to the clipboard:
#!/bin/bash
grim -g "$(slurp)" /tmp/screenshot.png
tesseract /tmp/screenshot.png - -l chi_sim+eng | wl-copy
rm /tmp/screenshot.png
-l chi_sim+eng does Chinese + English. Swap in whatever language packs you need.
Save it somewhere on your PATH and make it executable:
chmod +x ocr_screenshot.sh
sudo mv ocr_screenshot.sh /usr/local/bin/
Bind it in ~/.config/hypr/hyprland.conf — Super+O to OCR anything on screen:
bind = SUPER, O, exec, ocr_screenshot.sh