CUPS, 2-Sided Print Settings Etc. Ignored
How to fix the issue where user-specified print settings in GTK applications are silently ignored

Date: [2024-08-14 Wed], corrections [2024-09-26 Thu]

Why are your documents printing single-sided even though you explicitly specified 2-sided? Here are some answers at last, after first experiencing the issue 3 years ago.

Problem

You connected a printer to your LAN and allowed CUPS to configure it automatically (through the cups-browsed daemon). You wish to print a document 2-sided, so you open it in evince (or atril), select the Print command, and then specify 2-sided printing on the Page Setup tab. You decide you don’t need color either, so you also opt for gray-scale printing (Color tab).

[GTK Print Dialog]

Figure 1: GTK Print dialog: You select 2-sided printing. This should work, but it does not.

The printer heaves a sigh, whirs its gears into motion, and out comes… a single-sided document printed in color. Ugh! What happened?

Troubleshooting step: eliminating GTK

The problem is most likely gnome-control-center!2463. In this case, printing from a non-GTK application will bypass the problem. Fortunately, CUPS provides a built-in command to print a document. If your document is in a supported format (such as PDF), then you can run lp on it to print it.

lpstat -p
lp -d HP_Color_LaserJet_MFP_M283fdw_EEE9D9 -o sides=two-sided-long-edge foo.pdf

The first command lists the names of all printers connected. Be sure to pass the correct printer name to -d.

If the document prints 2-sided, then you have been bitten by gnome-control-center!2463. Read the next sections for a workaround.

(Hint: if you are doing a lot of troubleshooting, it might help to create a blank two-page document which you can feed through your printer repeatedly. Create a new document in LibreOffice, press <Ctrl>+<Enter> to insert a page break, and then File > Export As > Export as PDF.)

What’s really going on?

When cups-browsed configures a new printer, it creates an “implicitclass”. An “implicitclass” printer makes GTK lean on the GNOME system preferences and ignore any overrides in the individual application’s Print dialog.

So, another way around the issue is to launch gnome-control-center printers and change the system-wide 2-sided setting there. However, doing so uncovers another problem. gnome-control-center writes settings directly to the system-wide printer description file (PPD) housed in /etc/cups/ppd/. This works, but it is a deep customization in my opinion. You shouldn’t need to modify the printer description file.

[GNOME Control Center]

Figure 2: gnome-control-center: You can override system-wide defaults in GNOME Control Center, sort of.

See cups-browsed!15 for the entire story.

The short story is that anything you do in gnome-control-center on an “implicitclass” printer performs a deep system-wide customization, and individual overrides are still ignored. There must be a better way.

Disabling cups-browsed

Reading the aforementioned two bugs, I get the impression that “implicitclass” is a new thing, and GTK does not yet fully support it. So, a better way around the original issue is to disable automatic configuration.

This is not as scary as it sounds. You will need to add your printer to CUPS’s inventory once, but after that things will just work. Also, CUPS will still help you search the network for printers soliciting their services.

First, disable cups-browsed

# systemctl disable --now cups-browsed

Now, you must add your printer manually. There are a couple ways to do this.

The most ubiquitous way is to use the CUPS web interface. Point your web browser to http://localhost:631/. Go to Administration > Add Printer. CUPS will scan your network for printers and then prompt you for the one you wish to add. Create a legible name for your printer, and select the printer description file (PPD) that most closely matches your printer.

[CUPS Web Interface]

Figure 3: You launch the CUPS web UI to add a printer. Select ‘Add Printer’.

[Add Printer - CUPS Web Interface]

Figure 4: CUPS runs a network scan. You see a bunch of different configurations for the same printer. Try one. If you don’t like it, press Back and try again.

[Name Printer - CUPS Web Interface]

Figure 5: You type in a human readable name for the printer.

[Name Printer - CUPS Web Interface]

Figure 6: CUPS asks you for a printer description file (PPD). Pick the one that most closely matches your printer.

A second way is to use system-config-printer, which is the old GTK wrapper for CUPS. Unlock the settings and select Add. Follow the wizard to scan for printers on your network. Create a legible name for your printer, and select the printer description file (PPD) that most closely matches your printer.

[system-config-printer]

Figure 7: You launch system-config-printer. Unlock the application and press Add.

[Select Device - system-config-printer]

Figure 8: Select the network configuration you want.

[Describe Printer - system-config-printer]

Figure 9: Name your printer.

A third possible way (which I have not tested) is to use gnome-control-center, but at this moment do you really trust gnome-control-center to do the right thing?

You can now specify 2-sided overrides in the Print dialog of GTK applications.

[GTK Print Dialog]

Figure 10: GTK Print dialog: 2-sided printing now works correctly.

Another unsolved issue

Apparently GTK has another way of automatically configuring printers, even after disabling cups-browsed. See gtk!3314. To summarize, you might see a duplicate entry for your printer in the Print dialog, but you will only see this in GTK applications and not QT applications. This is because GTK has some logic to look for zeroconf/mDNS printers on the network.

This is why I recommend using human-readable names for the printers you configure manually. That way, the configuration that works is easiest to find.

Your mileage may vary with these zeroconf/mDNS configurations. In my personal testing, they respected 2-sided overrides from a GTK application. However, I still use the manually configured CUPS printer. (In fact, when I revisited this procedure to take screenshots, I could not reproduce the zeroconf configurations.)

Conclusion

There you have it: a little bit of gonzo-journalism about printing on GNU/Linux. It took me three years to nail down this problem, and I finally did. APIs change in this brave new world, and libraries try to keep up. Trees grow, and the world keeps on spinning.

If you have experienced this same insanely hard-to-troubleshoot problem that I have had, I hope this article helped you, and even if it did not help you, I hope you enjoyed it.

Configuration details

  • Printer: HP ColorLaserJet MFP M282-M285, connected to WiFi
  • OS: Debian 12 bookworm
  • Desktops: gnome-1:43+1, xfce4-4.18
  • Software: atril-1.26.0-2+deb12u3, cups-2.4.2-3+deb12u5, evince-43.1-2+b1, gnome-control-center-1:43.6-2~deb12u1, system-config-printer-1.5.18-1