Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Capturing a Screen Region with PipeWire and Extracting Text via Tesseract

Description and use

The script automatically captures a specified screen region, extracts the number via OCR, and notifies the user when the value changes, eliminating manual copy‑paste.

Problem

Manually copy‑pasting numbers from a dashboard that has no API becomes a bottleneck.

Outcome

The script automates KPI monitoring, eliminating manual copy‑paste, providing instant alerts, and consuming <0.2 s CPU per cycle.

Workflow

  • Install required tools: pipewire, grim, tesseract-ocr, imagemagick, jq, libnotify-bin.
  • Define REGION geometry and IMG_PATH variables.
  • Capture the region with grim: grim -g "$REGION" "$IMG_PATH".
  • Optionally preprocess the image with ImageMagick to improve contrast.
  • Run tesseract with --psm 7 to extract a single line of text and strip whitespace.
  • Store the previous reading in a temporary file and compare with the current reading.
  • If the value differs, send a desktop notification with notify-send and update the state file.
  • Loop the process every minute in a Bash script.
  • Run the script as a systemd user service for persistence and logging.

Evidence

You stare at a web‑based dashboard, manually copy‑pasting a handful of numbers every hour.

Source

In this post I walk through the exact setup I use on my home server: a PipeWire screen capture, a tiny grim script to grab a region, Tesseract OCR to read the numbers, and a Bash loop that notifies me via notify-send when the value differs from the previous run.

Source

The core loop stores the previous reading in a temporary file. When the new reading differs, we fire a notification.

Source

  • Record date: 2026-10-15T19:55:58.953Z