How to add printer with lpadmin and have it show up in Printers and Scanners in System Preferences?

I am using Mojave, and I am able to add a printer using lpadmin. I can then print a test page to that printer using the CUPS web interface. Additionally, the printer is listed with lpstat -p. However, the printer does not appear in the Printers & Scanners preferences pane, so it is inaccessible from other applications.

Here is the lpadmin command I am using:

lpadmin -p MyPrinter -E -v lptone:/path/to/file

This printer is using a custom CUPS backend (lptone) that is a script that generates a file name using a UUID and then writes the printed content into that file, so the /path/to/file portion of the URI is ignored. I know this part works because I can print a test page to this printer from the CUPS web interface, and I get a file with the test page content generated at the path where the script is supposed to put it. I have tried doing lpadmin as myself and with sudo.

If I first add the printer using the Printers & Scanners preferences pane (address=localhost:631, queue=printers/MyPrinter), then use lpadmin -p MyPrinter -v lptone:/path/to/file to adjust the output device (i.e., CUPS backend), the printer remains in the Printers & Scanners preferences pane, and I can print to it from other applications.


Solution 1:

Have you tried this? Add an IP printer with command line. It looks like there are some options that you might be missing that will identify the printer in Printers and Scanners.