Adding an AirPrint Printer the Easy Way

Update: 2022-2-13

You’ll have to forgive me if this is a little non-sensical, but I just spent seven or eight hours writing stuff based on a misunderstanding of work that had come previously 😐 . This was my fault for misreading what apizz was doing with his script that he wrote on October 30, 2019. I just realized tonight that he’d followed it up with this from May 26th, 2021, and the follow up script helped something click in my brain that hadn’t before.

My interpretation of what apizz was doing was that he was using the script in the 2019 post to generate PPD files for each of the printer models he was managing and deploying those into place along with icon files when deploying a printer. I don’t know why I read it that way, but that’s what I mean in this post when I say it felt like he was doing things the old way(deploying drivers along with install scripts). He was not (I don’t think but I don’t know what’s real anymore).

Tonight, after looking through the second script he posted in 2021 to fix the icon issue, I realized my assumption would have been a ridiculous way to handle it and that what he’s actually doing is much simpler: just run the script to generate the PPD on the device that you’re adding the printer to and add the printer in the same script. The only thing left to manage at that point is the script that’s generating the PPD.

apizz was kind enough to read this post and rightly criticized a number of points that I made, mostly in my sections titled “The Failures”(this was always intended to indicate my own failures, not anyone else’s, I’m realizing now that that was a poor choice of section heading title) and “Another Option”.

Concerning the failures, again: they were entirely failures of understanding and implementation of my own making. Concerning the other option, apizz mentioned in his comment that it resembled his own solution. I’d argue that that’s like saying an ingredient list for lasagna resembles the final product. The point I was trying to make was that someone could, if they wanted, start with the lpadmin command that I mentioned and build something workable. Which apizz did. In 2019. Then made it better in 2021.

I’m up to 2000 words written for this blog post (600 of which are about to get deleted because they’re embarrassing because I still hadn’t understood what I’d misunderstood about apizz’s post. Man I sure hope I’ve understood it now), which is entirely too many words when all I really needed to say was:

“Hey folks, I found a neat thing: open -a "/System/Library/CoreServices/AddPrinter.app" ipp://printerHostName“.

Sorry, apizz. Thanks for taking the time to help me be a better writer and better Mac admin.

All that said, I’d skip “The Failures” and “Another Option” down below and if you think what I’ve written is dumb go check out apizz’s posts because he can show you how to deploy a printer without user interaction. Mine is for Self Service only.

Original Post:

If you want to get right to the nitty-gritty and bypass +/- 1000 words about a one-line shell command you can check out my script on GitHub. If you want to know why I did what I did, it beats me but you may find some insights below.

This week I’ve at last finalized a solution to a problem that’s bedeviled me for four or five years. When I first started as a baby Mac Admin in the second half of 20151 adding printers with a tool like Munki or Jamf was mostly a solved problem.

Things have come a long way over the last six and a half years, though, and the methods that were best practice back then have all pretty much stopped working. Printer drivers were deprecated or are being deprecated or I don’t even know anymore, and heaven help you if your printer software has 32-bit components. Hopefully my suggestions below provide you a shortcut and your journey is shorter than mine.

The Problem

I needed a way to add printers to Jamf Self Service so my coworkers can add relevant printers for themselves easily whenever necessary. I needed the method I settled on to be able to add the printers as AirPrint printers using the Internet Printing Protocol to simplify the installation and so there wouldn’t be any extra packages to install and manage.

The Failures

You’re get to skip through years of frustration in 4 paragraphs. Enjoy.

Failure Number One

I came across a number of options over the last three or four years that I couldn’t get working reliably in my environment. Things like this thread on Jamf Nation and this one from Apizz led me down months-long rabbit trails trying to get ippfind and ipp2ppd to give me what I wanted.

To be quite frank, I think the problem with those solutions was that they were trying to deal with AirPrint in an old way.

Failure Number Two

The other option that I found unworkable was adding printers with Configuration Profiles through my MDM solution(Jamf). Adding printers to Jamf was a pain and rarely resulted in a working, deployable configuration for me.

It’s entirely likely that I was holding it wrong adding the printers incorrectly but this was another solution I worked on for months and couldn’t get working reliably.

The Solution

Having stared at the problem long enough I finally had a bit of an unexpected thought: “I wonder if anything in macOS is registered to handle ipp:// URLs”.

In a moment of pure desperation I typed the ipp:// URL for the department printer into the address bar in Safari and

Confirmation dialog box in Safari to open AddPrinter.app.
Open in AddPrinter.app

WHAT?!

I clicked “Allow” and

Confirmation dialog box for communicating with the printer.
Clicking “Continue” will communicate with the printer.

WHAT?!?!

I clicked “Continue” and

Printer added to Printers & Scanners Preferences pane.
My wife’s printer. Successfully added.

Well that was easy. I could automate that. Some of you may be seeing what I missed, but that was good enough for me. I rolled right ahead with Safari, problem solved:

open -a "Safari" ipp://deptPrinterHostName

(don’t use that command, the good one comes later)

There was my department printer added to my computer, pretty icon and all. It even added the fax machine2!

I created a policy for each of the printers I needed using the Files and Processes option to run that command and shoved them all into Self Service.

Refinement

I was happy as a clam till a few months later. Towards the beginning of February, 2022 I was cleaning up some policies in Jamf, thinking about how awesome I was and remembering how pleased I was with my printer solution.

I mentioned it to my buddy Adam3. When I showed Adam the command I was using, Adam asked a rather insightful question: “Why Safari?”

I don’t know, Adam. Gimme a minute to re-think everything I believe in.

With my genius firmly debunked I tried a couple of commands off the top of my head4 before opening the Add Printer app5 and pulling up Activity Monitor. Sort by name, double click the Add Printer process and select the “Open Files and Ports” tab to reveal the droid we’re looking for: /System/Library/CoreServices/AddPrinter.app. And sure enough, AddPrinter.app is registered to handle ipp:// URLs. Hooray!

That gives us the rather tidy

open -a "/System/Library/CoreServices/AddPrinter.app" ipp://printerHostName

to add a printer. Run the command and confirm you want to connect to the printer. The Add Printer app opens, connects to the printer and closes again.

Super clean and simple and it only took me like 5 years to figure it out.


Another Option

In getting this all typed up I ran across the following:

lpadmin -p BrotherPrinter -E -v ipp://brw8cc84b465a44.local/ipp/print -m everywhere

This works but has a couple of drawbacks I don’t like:

  • It adds the printer with a generic printer icon. This is trivial, but I think it does make for a worse experience for my coworkers, especially if they have multiple printers
  • It adds the printer using the IPP Everywhere PPD which seems to not pull as much info from the printer as my method. This affects little things like supply level bars being black instead of the color of toner they represent. Again, trivial things but the AirPrint method seems to make for a nicer experience

One advantage of using the lpadmin command is that it doesn’t require user interaction. If you need to add printers automatically with a script it might be worth investigating that a little further to see if you can specify some of those additional details that will make the user experience a little better. I found the lpadmin command here. That link and this one would be a good place to start your research.

For my part I’m going to stick with:

open -a "/System/Library/CoreServices/AddPrinter.app" ipp://printerHostName


Footnotes

1: I’m now a toddler Mac Admin. We mature slowly. ⤴︎

2: I don’t actually care about the fax machine but maybe you do? ⤴︎

3: open -a "Sytem Preferences" ipp://printerHostName; open -a "Printers & Scanners" ipp://printerHostName; and open -a "Add Printer" ipp://printerHostName if you must know. ⤴︎

4: You probably know Adam if you’re reading this. ⤴︎

5: System Preferences > Printers & Scanners > “+” ⤴︎

Advertisement

4 thoughts on “Adding an AirPrint Printer the Easy Way

  1. Glad to have found this blog post and the civil communication between apizz and daboyter concerning its contents. 🙂

    My thoughts are mostly if there’s any advantages or disadvantages to add the printer via AirPrint compared to going the lpadmin route? If I understand correctly AirPlay is simply a different way to the same goal in that it helps make it easier to add the printer since it ”broadcasts” itself via Bonjour.

    In the command in this article the printer is added via IPP, but could it just as well be added as LPD? I have an lpadmin script that works well where the printers are added using LPD, so I guess my question is if there are any of these methods that are preferable over the other?

    Thanks in advance for any insight shared!

    Like

    • Hello, star-affinity, thanks for reading and commenting. I’m probably the wrong person to ask about what’s going on behind the scenes here, but on a surface level if you use the method I described (`open -a “/System/Library/CoreServices/AddPrinter.app” ipp:\printerHostName) it will require user input to finish adding the printer. That’s what those dialogue boxes in the screenshots are. That works for me because I want user interaction.

      In the post I linked in the update apizz has created a script that you can feed some basic printer information to, then deploy and it should add a printer without any user input. You could fully automate that based on any number of criteria or put that script into a self-service policy and you’ll get a similar experience to doing what i did.

      Functionally, as I understand it, the main difference is that mine will require an extra click in the Add Printer application.

      Like

  2. Can you elaborate on this?: months-long rabbit trails trying to get ippfind and ipp2ppd to give me what I wanted.

    To be quite frank, I think the problem with those solutions was that they were trying to deal with AirPrint in an old way.

    I don’t understand what you mean by dealing with AirPrint in an old way. Can you explain?

    To be clear, your solution is interesting and one I’d not run across before and plan on trying myself. but from an argument standpoint, your statements about challenges with those other workflows without any level of discussion about why they didn’t work or what they lacked compared to what you needed make it difficult to understand why your solution is better.

    I personally take issue with your “another solution” section at the end with the lpadmin method. If you had read my blog post, I think you would find that the script I came up with effectively does what this does with the lack of printer icon (although I revised it to collect an icon). I try to give credit where credit is due and if you’re going to acknowledge someone else’s work as problematic but then suggest an alternative solution which is basically the same as this and not acknowledge that fact, you simultaneously betray the better solution you found while also fail to acknowledge that you ultimately see value in the solutions you previously claim as problematic. I’m assuming you didn’t mean it this way, but I think as a member of the MacAdmin community it’s our responsibility to build on one another’s work, acknowledging where previous solutions fall short in a clear and respectful way while effectively articulating what’s better about your solution. Ultimately I appreciate this new method, but what I don’t appreciate is the suggestion that my work / solution doesn’t work or isn’t viable with no statement at all as to why.

    Again, I do appreciate your addition to the dialogue and look forward to trying your Add Printer method, but I hope you’ll be more cognisant about how you choose to communicate and reference other people’s work.

    Liked by 1 person

    • Hi apizz, first of all, I owe you an apology. I didn’t consider how this post was interacting with other work on the topic and I did give short shrift to your post. I was excited to share what I’d discovered and didn’t take time to address the work that’s come before. I’m sorry for handling that poorly.

      I appreciate the benefit of the doubt. It was, indeed, not my intention to dismiss or belittle your’s and other’s work in this area. My comments were born out of a great deal of frustration with printers in general(and in our environment) and not with your work in particular, but I was not considering the impact my words would have on others.

      I want to address your comments in detail but I’m going to do that in the post itself because I think the issues you raised deserve a considered, and public, response rather than shoving something down below in the comments.

      I should have some time to work on that tonight after putting the kids to bed, but I wanted to add a quick note to thank you for taking time to correct me. I was not thinking about how my post was interacting with the rest of the work in the field and I’ll work on considering that when I write posts in the future.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s