No description
Find a file
2026-05-01 14:56:53 +01:00
datasets Use bundled digit templates by default 2026-05-01 13:51:43 +01:00
reforger_queue Release 0.9.0 watcher alerts 2026-05-01 14:56:53 +01:00
templates Use bundled digit templates by default 2026-05-01 13:51:43 +01:00
.gitignore Release v0.7.5 portal-only refactor 2026-05-01 14:18:16 +01:00
.python-version initial v0.1 APT 2026-05-01 10:26:41 +01:00
main.py initial v0.1 APT 2026-05-01 10:26:41 +01:00
Makefile Release v0.7.5 portal-only refactor 2026-05-01 14:18:16 +01:00
portal_capture_frame.cpp Add portal window capture backend 2026-05-01 13:05:49 +01:00
pyproject.toml Release 0.9.0 watcher alerts 2026-05-01 14:56:53 +01:00
README.md Release 0.9.0 watcher alerts 2026-05-01 14:56:53 +01:00
reforger_queue_read.py Release v0.7.5 portal-only refactor 2026-05-01 14:18:16 +01:00
uv.lock Release 0.9.0 watcher alerts 2026-05-01 14:56:53 +01:00

Anti Prestige Tool v0.9.0

Queue-position reader for Arma Reforger on Linux Wayland.

The tool captures a user-selected Reforger window through xdg-desktop-portal/PipeWire, crops the queue-number region, and reads the orange UI digits with bundled real-game digit templates. Normal use does not require external OCR libraries, desktop-specific screenshot hooks, or a specific installed font.

Install

Install system dependencies:

# Arch example
sudo pacman -S --needed base-devel uv qt6-base gstreamer gst-plugins-base gst-plugin-pipewire imagemagick xdg-desktop-portal

Install the portal backend for your desktop:

KDE:   xdg-desktop-portal-kde
GNOME: xdg-desktop-portal-gnome
wlr:   xdg-desktop-portal-wlr

Set up the Python environment and build the portal helper:

uv sync
make

No sudo install step is required.

Standard Run

Watch the selected Reforger window and alert when the queue position reaches 5 or lower:

uv run reforger_queue_read.py --watch --portal-window

On first run, your desktop should show a window-sharing picker. Select the Arma Reforger window. Later runs try to reuse that selection.

Read the queue once:

uv run reforger_queue_read.py --portal-window

Force the window picker again if the saved selection is stale or wrong:

uv run reforger_queue_read.py --portal-window --portal-reselect

Run once with crop and OCR details while tuning or checking accuracy:

uv run reforger_queue_read.py --portal-window --show-crop --debug

The saved portal restore token lives here:

~/.local/state/anti-prestige-tool/portal-window-restore-token

Watch Behavior

Default watch mode:

poll interval: 15 seconds
alert threshold: 5, inclusive
alerts: once per newly detected position
notification urgency: critical

Each poll prints a timestamp, the detected queue number, and whether an alert fired:

2026-05-01T14:44:05+01:00 number=5 alert=yes
2026-05-01T14:44:20+01:00 number=5 alert=no

If no digits are found, the watcher logs that and keeps running.

Optional Flags

Common flags:

--watch                      keep polling instead of reading once
--watch-interval SECONDS     poll delay; default 15
--alert-threshold N          alert when position is <= N; default 5
--portal-reselect            ignore the saved portal selection and pick again
--show-crop                  print the resolved crop
--debug                      print OCR match details
--save-input PATH            save the captured portal frame
--notify-command COMMAND     notification command; default notify-send

Input and test flags:

--image PATH                 read an existing screenshot
--dataset DIR                read every image in a dataset directory
--expect-filenames           compare dataset results to numeric filenames
--font FONT                  debug with synthetic font templates
--crop X,Y,W,H               override the crop
--cropped                    treat input image as already cropped

Examples

Alert at queue position 10 or lower:

uv run reforger_queue_read.py --watch --portal-window --alert-threshold 10

Poll every 5 seconds:

uv run reforger_queue_read.py --watch --portal-window --watch-interval 5

Save the captured input image while debugging:

uv run reforger_queue_read.py --portal-window --save-input /tmp/apt-portal-window.png --show-crop --debug

Test watcher alerting against a fixture without sending a real notification:

uv run reforger_queue_read.py --watch --image datasets/regression-test-set/3.png --watch-interval 1 --notify-command true

Read an existing screenshot:

uv run reforger_queue_read.py --image /path/to/screenshot.png --show-crop --debug

Validation

Run the regression set:

uv run reforger_queue_read.py --dataset datasets/regression-test-set --expect-filenames

Expected result:

summary: 21 passed, 0 failed

Run the smaller smoke dataset:

uv run reforger_queue_read.py --dataset datasets/scootz-dataset --show-crop

Expected output:

datasets/scootz-dataset/1920x1080.png	crop=788,465,75,45
datasets/scootz-dataset/1920x1080.png	22
datasets/scootz-dataset/2160x1440.png	crop=1050,620,100,60
datasets/scootz-dataset/2160x1440.png	24

Debug Options

The default matcher uses bundled templates from:

templates/reforger_digits.json

Font mode is only for debugging. Known-good overrides:

uv run reforger_queue_read.py --portal-window --font Roboto-Condensed --show-crop --debug
uv run reforger_queue_read.py --portal-window --font Adwaita-Sans --show-crop --debug

Default crop reference:

reference-size: 2560x1440
reference-crop: 1050,620,100,60
scale-mode: width

Portal restore behavior depends on the desktop portal. If the selected window disappears after an Arma restart, the portal may show the picker again.