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