Repository navigation
Add a Printers widget that reads printers over IPP - #24
Open
masonjmiller wants to merge 1 commit into
Open
masonjmiller wants to merge 1 commit into
masonjmiller wants to merge 1 commit into
Conversation
Printers are the other thing on a desk that wants watching: whether one is
ready, why it isn't, and how much ink is left before a job runs out of it.
Every printer that works with AirPrint or Mopria answers the same question
over IPP, the Internet Printing Protocol, so one small request covers nearly
every printer of the last decade with no driver, account or setup.
PrinterService finds printers the way the Print dialog does, over Bonjour as
_ipp._tcp and _ipps._tcp, and asks each for its attributes every 30 seconds,
every 5 while one is printing. Printers that refuse plain IPP with HTTP 426
are asked again over TLS; their certificates are ones they made themselves,
which macOS's own printing accepts too, and only a status request goes out.
A printer that stops answering keeps its last status, with the problem beside
it, because ink doesn't vanish when a printer sleeps.
IPP.swift is just enough of RFC 8010 to send Get-Printer-Attributes and read
the reply, skipping the collections and types the widget has no use for.
PrinterStatus turns the reply into words: the state, the most serious of the
printer-state-reasons ("Out of paper", "Cover open"), and the marker-*
attributes as supplies with names, levels and the printer's own sRGB colors.
The widget lists every printer, or gives one the whole tile with its ink
tanks drawn in their colors, outlined in red when the printer says one is
low. A tap opens the printer's web page. A new config field type,
printerPicker, lists the printers found while the app runs, and keeps a
chosen printer in the list while it is switched off.
The tests read recorded replies from an HP Smart Tank and an Epson SC-F100.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
masonjmiller
marked this pull request as ready for review
October 8, 2026 16:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A native Printers widget (Network): the state, problems and ink levels of the printers on your network. Like the Cameras widget (#22), I built it with Claude.
What it does
How
IPP.swiftis just enough of IPP (RFC 8010/8011) to send Get-Printer-Attributes and read the reply. It handles multi-value attributes andtextWithLanguage, and skips collections. There's no CUPS and no third-party code.PrinterStatusturns the reply into the widget's terms:printer-state;printer-state-reasons, with severity from the-error/-warning/-reportsuffix;marker-*attributes as supplies with names, levels and sRGB colours, where -3 means "some left";printer-more-infofor the tap.PrinterService(ServiceKey.printers):_ipp._tcpand_ipps._tcp, preferring IPPS when a printer offers both;A printer that answers plain IPP with HTTP 426 is asked again over TLS.
PrinterTransportis injectable, so the tests run without a printer.ConfigFieldType.printerPickerlists the printers found while the app runs, next tonotePickerfor the same reason: its options can't be in the schema. A chosen printer that's switched off stays in the list as "(not found)", so it doesn't quietly revert to All Printers.Info.plist:
NSLocalNetworkUsageDescription, plusNSBonjourServicesfor the two IPP types.The printing colour is the widget's primary (cyan), settable on the Theme page like the other Network widgets.
Choices worth a look
Testing
xcodebuild testpasses in full: 415 Swift Testing tests in 40 suites, plus the XCTest suite. 28 of the tests are new, in three suites: IPP encoding and decoding, status interpretation, and the service, including the 426 retry and the scoped-address fix.Scripts/ci-local.sh allpasses: the format check is clean and there are no compiler warnings.Overlaps with #22
This touches the same places as #22 (Cameras):
ConfigFieldType,ServiceKey,AppModelandWidgetRegistry;NSLocalNetworkUsageDescription;Whichever lands later, I'll rebase.
🤖 Generated with Claude Code