OpenBSD lpr/lpd in 2021
2021-11-26 · 1320 words · 7 min
TagsĀ :  OpenBSD


HP Deskjet 450Portable Inkjet, USB, hpijs driver
Kyocera Ecosys 2040dnMonochrome Laser, NIC, PostScript 3

Yes, i was printing with CUPS over the last years, like 95% of the people on a Mac or Linux/Unix. The Kyocera is a PostScript capable printer, they call it KPDL but it just another name for PostScript.
Searching for a ppd-file on their webpage and reading a bit, easy going with CUPS.

So, why go back in the early years and do that to yourself?

My HP Deskjet is ancient, but i love it. This machine is slow but compact and portable, with cheap ink and (for me) okayish quality. Printing five times a year something in color with decent paper ... never had any problems. However, i run into problems with CUPS. Configuring USB was not that easy, together with other problems. (/dev/ulpt0 must be deactivated, /dev/ugen is the way, i don't feel good about this)

I also have to confess that i never had successfully and stably created a /etc/printcap before. Years ago, i failed that task every time. Later at Windows i was using huge binary packages followed by OSX with CUPS.

I'm curiuous about it. How is it working all together? What about the footprint and speed, the network-capabilities and is it possible to ditch the CUPS system complete?

Time for the basics. Forget the printer related ppd-file, this belongs to CUPS. The easiest way is a network printer, PostScript capable. For this machines you only need to edit the /etc/printcap file correctly. Some tuning can be done with various filters or selfmade scripts.

The HP Deskjet 450 is not capable of PostScript language. A quick research guided me to and some information about characteristics and the recommented driver.

Let's go, we are on

$uname -srp
OpenBSD 7.0 amd64

If the CUPS system is already running, we have to stop the daemon

$doas rcctl stop cupsd

Removing cupsd from the init-system /etc/rc.conf.local, so that there are not two competing systems and maybe cause problems under the path /var/spool/

$doas rcctl disable cupsd

Removing the software package

$doas pkg_delete cups

Ok, maybe there are unused dependencies

$doas pkg_delete -a

Starting the lpd daemon

$doas rcctl start lpd

Create or copy the /etc/printcap

$doas cp /etc/examples/printcap /etc/printcap

The original file with my minimal adjustments

        $OpenBSD: printcap,v 1.2 2016/03/05 16:24:56 ajacoutot Exp $


:sh=no summary-page after printing
:rm=remote address, or the hostname if you have your dns under control
:sd=directory for print jobs, spooler directory
:lf=logfile directory

That's it. Simple, minimal and works with a

$ lpr -P lp ~/test.txt

And now, what's with the HP Deskjet and this hpijs driver? The hpijs is part of the hplip package, but we don't need the complete package. Probably this hplip or (overkill) hplip-gui installation drags more packages than I have installed in total. I have the feeling that one or two filters will have to be added sooner or later.

There is a filter-script called apsfilter. This is awsome, must be there since the nineties since 1994. The webpage is down, here a nice overview. It offers the guided possibility to select drivers and define the printing parameters. The scripts then generate a ready-to-go /etc/printcap file.

We install the package

$doas pkg_add apsfilter 

Pay attention

$man apsfilter

Next step, starting the setup-script

$doas /usr/local/share/apsfilter/SETUP

Just follow the text-based questions. From i know that the Deskjet 450 is technically a twin of the Deskjet 990. Because of that, i go this route

1) Printer Driver Selection
12) HP Deskjet drivers (hpijs 1.1 and later)
53) HP Deskjet 990

The other settings are to be adapted to the personal flavour.
Following the (T) option will generate a Testpage, but this was failing. The driver hpijs is missing. Yes, of course.

$doas pkg_add hpijs

Great, which version is it? Apsfilter requires 1.1 and later

$pkg_info -Q hpijs
hpijs-3.21.8 (installed)

Perfect. A lpd restart

$doas rcctl restart lpd

Now the Testpage is printing. After playing a bit with the settings, i finally skipped the photo quality mode. This mode was really slow and i cannot see any difference to the high mode on my paper.

The /etc/printcap looks like this

# APS1_BEGIN:printer1
# - don't delete start label for apsfilter printer1
# - no other printer defines between BEGIN and END LABEL
# APS1_END - don't delete this

The setup-script has automatically generated entries with our information.

First line with the name|driver and our options for the printer.
Second line is the applied filter-package.
Third line is the (changed) spool-directory.
Fifth line is the (changed) log-directory.
Sixth line is the (new) accounting directory.
Seventh line is (new) for the max-file size. 0=unlimited.
The last line will disable a summary-page after printing.

To add a PostScript Laserprinter, just open the setup-script again and Continue > Accept Licence > Request Snail Mail > RETURN > RETURN > Permissions correct > a) to (a)dd another printer entry

Choose PostScript printer (generic) as driver. The other settings depend on the technical data and personal preferences.

This can safe a lot of time
Most models have a selection of the printer control language in hardware. (PS, PCL, KPDL, ZPCL, EPL, ZPL, Epson ESC/P). I need KPDL for my Kyocera. Checking the setting can safe a lot of nerves and paper.
Some models have a selection for the printing protocols (IPP, IPP/SSL, RAW, LPD etc.). LPD has to be switched on. Activating the minimum necessary services has always been worthwhile so far.

Final /etc/printcap file

# APS1_BEGIN:printer1
# - don't delete start label for apsfilter printer2
# - no other printer defines between BEGIN and END LABEL
# APS1_END - don't delete this
# APS2_BEGIN:printer2
# - don't delete start label for apsfilter printer1
# - no other printer defines between BEGIN and END LABEL
# APS2_END - don't delete this

Don't forget to enable the lpd daemon. Until now, he won't survive a reboot, so ...

$doas rcctl enable lpd


In the end, it was a failing experiment. Apsfilter works and these filters exist for over 1/4 century and do what they are supposed to. Crazy. Unfortunately the form of deployment is not the smartest and theoretically it could be managed with 1 or 2 lines (for a postscript printer) + script in /etc/printcap. Installation shouldn't be necessary, but I haven't managed to control duplexing cleanly yet. In the meantime I'm using the CUPS system again, once configured it works. When I have some real time again, I'll take another look at the whole thing.

tech · about · visual · contact · home