A fast, on-device OCR solution for GNOME Wayland - select any area of your screen and get the text copied straight to your clipboard, no intermediate image save required.
- You want to copy text from an image, video, or non-selectable UI element
- You don't want to save a screenshot and manually run OCR on it
- You want it all triggered by a single keyboard shortcut
sudo dnf install -y gnome-screenshot tesseract wl-clipboardFor non-English text, also install the relevant language pack, e.g.:
sudo dnf install -y tesseract-langpack-hin # Hindi
Create the script file:
mkdir -p ~/.local/bin
nano ~/.local/bin/ocr-screenshot.shAdd this content:
#!/bin/bash
# On-device OCR screenshot - copies recognized text directly to clipboard
# Dependencies: gnome-screenshot, tesseract, wl-clipboard
FILE=$(mktemp /tmp/ocr-screenshot-XXXXXX.png)
gnome-screenshot -af "$FILE" && \
tesseract "$FILE" stdout --oem 1 -l eng 2>/dev/null | \
wl-copy
rm -f "$FILE"Make it executable:
chmod +x ~/.local/bin/ocr-screenshot.sh- Open Settings → Keyboard → View and Customize Shortcuts
- Scroll down and click "Add Custom Shortcut"
- Fill in:
- Name:
OCR Screenshot - Command:
/home/YOUR_USERNAME/.local/bin/ocr-screenshot.sh(replaceYOUR_USERNAME) - Shortcut: Press your desired key combo (e.g.,
Super + T)
- Name:
Press your shortcut, select the area with text, and the recognized text will be:
- Copied directly to clipboard - ready to paste anywhere
- No screenshot file saved to disk
- No image ever touches your clipboard
| Part | What it does |
|---|---|
gnome-screenshot -af "$FILE" |
Takes an area screenshot and saves it to a temp file (no dialog) |
tesseract "$FILE" stdout |
Runs OCR on the image and outputs recognized text to stdout |
--oem 1 |
Uses LSTM engine only - faster and more accurate than legacy mode |
-l eng |
Explicit language selection, skips auto-detection overhead |
wl-copy |
Copies the piped text into the Wayland clipboard |
rm -f "$FILE" |
Cleans up the temp file immediately after |
Change -l eng to any language or combination:
tesseract "$FILE" stdout --oem 1 -l eng+hin 2>/dev/null | wl-copyFind available language packs:
dnf search tesseract-langpack- Fedora 43
- GNOME 49
- Wayland