Skip to main content

printer-cli

PyPI Python 3.11+ MIT license

Check ink, paper and alerts, run nozzle checks and head cleaning, print and scan on network printers, from a scriptable CLI or a full-screen TUI.

Install

uv tool install printer-cli

Requires Python 3.11+. Puts prt on your PATH (printer-cli works too). Other methods: Install options.

Quick start

Check a printer's ink, paper and alerts. No printer handy? The built-in demo printer replays a real Epson XP-6000:

prt -p demo status
╭─┐EPSON XP-6000 Series · office┌──────────────────────────────────────────╮
│ ● idle    firmware 20.50.NU30Q6 · up 4h02m                               │
├──────────────────────────────────────────────────────────────────────────┤
│ ink                                                                      │
│ Photo Black  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■····  92%               │
│ Cyan         ········································   1%  ✗ replace    │
│ Magenta      ········································   1%  ✗ replace    │
│ Yellow       ■■■■····································  12%  ▲ low        │
│ Black        ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■·····  89%               │
├──────────────────────────────────────────────────────────────────────────┤
│ paper   main A4 ✓   photo 4×6 ✓   disc Disc ✓   (levels not reported)    │
│ waste   ▲ almost full — service soon                                     │
╰─┘4 alerts · checked 17:42└───────────────────────────────────────────────╯

Next: Use your own printer · Commands · The TUI · Safety

Why printer-cli

It started because the Epson XP-6000's web dashboard stopped working. printer-cli talks to the printer directly over standard protocols (IPP, eSCL, SNMP, plus Epson's ESC/P2 remote mode for maintenance). It works with most AirPrint/Mopria printers from any brand, and you can manage several printers from one place.

Use your own printer

prt discover                                        # find printers on the LAN
prt printers add office EPSON721655.local --default # save one under a short name
prt status                                          # ink, paper, alerts
prt tui                                             # full-screen dashboard

Every command also works against the built-in replay: prt -p demo status, prt -p demo tui.

Status

Verified against the real XP-6000 Covered by tests (replay of its data)
Ink, state, alerts, paper, firmware (IPP) ✅ read live during development ✅
Page counter (SNMP) ✅ ✅
Scanner capabilities (eSCL) ✅ ✅
Scanning a page ⏳ not yet ✅ (mocked HTTP)
Printing (IPP / CUPS) ⏳ not yet ✅ (fake transport)
Nozzle check / head cleaning (ESC/P2 on 9100) ⏳ not yet: bytes match gutenprint escputil, port 9100 is open ✅ (byte-exact)

Commands

Command What it does
prt status [--watch N] State, alerts, ink, paper, waste pad. --watch prints one line per sample
prt ink Ink levels only
prt overview System, software and hardware: model, serial, firmware, uptime, page count, formats, media, scanner, capabilities
prt discover mDNS scan for printers and scanners
prt printers list/add/remove/default Manage saved printers
prt maintain nozzle-check Print the nozzle check pattern
prt maintain clean [--force] Head cleaning, with a safety check first (see Safety)
prt maintain test-page Colour test page: ink bars, gradients, grey steps, fine lines
prt maintain identify Flash the printer's panel
prt print FILE… [-n 2] [--media 4x6] [--tray photo] [--quality high] [--mono] [--duplex] Print
prt jobs [--all] / prt jobs cancel ID List or cancel jobs
prt scan [-o file.pdf] [--type jpeg] [--dpi 600] [--mode gray] [--area full] Flatbed scan (-o - writes to stdout)
prt tui Full-screen dashboard

Global options, which can go before or after the command:

  • -p/--printer NAME|HOST picks the printer.
  • -f/--format json prints machine-readable output.
  • --no-color turns colour off.
  • -q hides notes and prints only results.
  • --timeout S sets the network timeout in seconds.
  • --config PATH uses a different config file.

Scripting

prt ink -f json | jq -r '.inks[] | select(.state != "ok") | "\(.name): \(.level)%"'
prt status | grep '^alert'            # piped output is tab-separated, no colour
prt scan -o - --type jpeg > page.jpg

Exit codes: 0 ok · 1 runtime/network error (also when only cached status is shown) · 2 usage error · 3 bad input file · 130 Ctrl-C.

The TUI

prt tui opens a keyboard-driven dashboard. Inks are drawn as vertical tanks in their real cartridge colours, alongside system info, paper and alerts. Tabs: Dashboard · Maintain · Print · Scan · Jobs.

Key Action
r Refresh (auto-refreshes every 10 s)
n / c / i Nozzle check / head cleaning (both ask first) / identify
p / s / j Print, Scan, Jobs tabs
1–9 Switch between saved printers
q Quit

Safety

  • Head cleaning is refused while any ink is at or below its low level, or while the waste ink pad is flagged. Cleaning flushes ink into the pad, and a full pad locks the printer until it's serviced. --force overrides this, and the TUI offers "Clean anyway".
  • Nozzle check, cleaning and the test page ask for confirmation first. In scripts, pass --yes.
  • printer-cli never resets the waste ink counter or writes to the printer's EEPROM.

How it talks to printers

Feature Protocol Notes
Status, ink, info, jobs, identify IPP (631) Small IPP codec built in, no ipptool needed
Printing IPP Print-Job JPEG/PWG/URF go direct; PNG etc. are converted to JPEG; PDF and other files go through the local CUPS queue for the same printer, matched by UUID (the XP-6000 doesn't accept PDF)
Scanning eSCL / AirScan (443) Certificate checks are skipped for the scanner host only, because printers ship self-signed certificates
Page counter SNMP v1 Printer-MIB lifetime count
Nozzle check, cleaning ESC/P2 remote mode on 9100 Byte sequences from gutenprint's escputil (Epson only)

When the printer is asleep, status and the TUI show the last known status from ~/.cache/prt/, marked as cached.

Configuration

~/.config/prt/config.toml. Override the location with PRT_CONFIG or --config. Priority order: command-line flags > environment variables (PRT_PRINTER, PRT_TIMEOUT) > config file > defaults.

default = "office"

[printers.office]
host = "EPSON721655.local"

[printers.pantum]
host = "192.168.1.80"
driver = "ipp"

Install options

With pipx:

pipx install printer-cli

From source (add --editable to track local changes):

git clone https://github.com/luongnv89/printer-cli.git && cd printer-cli
uv tool install .

Optional tab completion for your shell:

prt --install-completion

Adding a printer brand

Drivers live in src/prt/drivers/:

  • IPPDriver covers any IPP Everywhere / AirPrint printer.
  • EpsonDriver adds maintenance and counters on top of it.
  • FakeDriver replays a captured fixture, for tests and the demo.

To add a vendor, subclass IPPDriver, declare its capabilities, override what it can do, and register it in drivers/registry.py. The CLI and TUI hide actions a driver doesn't support.

Development

uv sync
uv run pytest            # 88 tests, no printer needed
uv run prt -p demo tui

Troubleshooting

  • "cannot reach printer": the printer is probably asleep. Press any button on it, or check prt discover.
  • Shell completion isn't detected: write the script out manually, e.g. _PRT_COMPLETE=source_zsh prt > ~/.zfunc/_prt.
  • PDF won't print: add the printer in System Settings → Printers so a CUPS queue exists, or print a JPEG.

License

MIT © Luong NGUYEN

Metadata

Release files for printer-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for printer-cli 0.1.0
File Size Uploaded Provenance Actions
printer_cli-0.1.0.tar.gz 67.0 kB Without provenance Details for printer_cli-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for printer-cli 0.1.0
File Interpreter ABI Platform Actions
printer_cli-0.1.0-py3-none-any.whl Python 3 none any Details for printer_cli-0.1.0-py3-none-any.whl

Total release size: 134.3 kB

Release files / printer_cli-0.1.0.tar.gz

Download URL printer_cli-0.1.0.tar.gz
Size 67.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a55933d10acc5941d2479da9c701bb67e1a348566329fe5d30a4eb69636d0b24
BLAKE2b-256 checksum
How to use checksums
13d0f223a6714f4f099f39415c349f7d85d6edb4d2afbbdbc81b3249bf73f7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / printer_cli-0.1.0-py3-none-any.whl

Download URL printer_cli-0.1.0-py3-none-any.whl
Size 67.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0a928fcb6e91223177034d81e4415c94e50f1dbf1d6750fcefa19079656152f
BLAKE2b-256 checksum
How to use checksums
98492b727d1ffff29b70545a8ddaabddd04a017bf2b32157e78d339a9232ea72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for printer-cli 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page