Several years ago, I wrote a post about the challenges around using lpd:// for printing on Macs running 10.14 Mojave and later. While I came up with a workaround involving programmatically configuring printers to use AirPrint, I found a minor (but annoying) issue where configuring a printer in this way when run as root (which any management tool would do) would produce a PPD file without a printer icon. Running the same ipp2ppd binary as the logged in user did correctly include the printer icon.
A fellow MacAdmin came up with a clever workaround using outset for running the necessary script as the logged-in user, but I had hoped that my post would nudge others in the community to come up with a workaround to allow the inclusion of the printer icon rather than force others to implement another (albeit useful & powerful) tool. Unfortunately, this did not come to pass. The topic of the #printers-n-cups MacAdmins Slack channel is apt: Abandon all hope, ye who enter here …
Part of the ipp2ppd binary processing involves downloading all of the available printer icons (.png) from the printer and converting these into a single .icns file. As I learned years ago, these icons are discoverable using the ipptool and searching for printer-icons from the output.
Since the only difference between a root triggered call of ipp2ppd and a regular user call is this icon file reference in the PPD, it occurred to me that so long as it was possible to query and download just one of these PNG icons that this could be subsequently appended to the PPD file in order to install a printer in this programmatic way with an icon.
Sure enough, some tweaking later and I can confirmed the below script would successfully add several different AirPrint printers with their appropriate icons!
This file contains 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