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

Capturing a Screen Region with PipeWire and Extracting Text via Tesseract

Описание и применение

Скрипт автоматически захватывает заданный регион экрана, извлекает число с помощью OCR и уведомляет пользователя при изменении значения, устраняя необходимость ручного копирования.

Задача

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

Результат

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

Рабочий процесс

  • 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.

Доказательства

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

Источник

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.

Источник

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

Источник

  • Дата записи: 2026-10-15T19:55:58.953Z