Cups

From wikinotes

Cups is the standard linux method of interacting with printers and scanners.

Documentation

github https://github.com/apple/cups
homepage http://www.cups.org/

Tutorials

setup tutorials https://www.thegeekstuff.com/2015/01/lpadmin-examples/
FreeBSD cups https://docs.freebsd.org/en/articles/cups/
Brother linux drivers on FreeBSD http://www.reynoldsnet.org/freebsd_brother_cdw.html

Locations

/etc/cups/cupsd.conf config
/etc/cups/cups-files.conf permissions config
/etc/cups/printers.conf configured printers (incl. webui)
/var/log/cups/* logs
http://localhost:631 web interface

Install

Cups

pacman -S \
    libcups \
    cups \
    cups-filters \
    usbutils

pacaur -S ink              # (optional) ink levels

usermod -aG lp ${user}     # add user to lp group
usermod -aG wheel ${user}  # add user to wheel group (permission to print)

systemctl enable cups.service
systemctl start cups.service

# print-queue web interface
systemctl enable cups-browsed.service
systemctl start cups-browsed.service
http://localhost:631

Drivers

epson

# canon, epson, lexmark, sony, olympus, pcl
pacman -S gutenprint

brother (general)


See https://github.com/pdewacht/brlaser for supported options

aur sync brlaser
pkg install brlaser


brother hl2390dw


aur sync brother-hll2390dw

When adding printer and it prompts for PPD, choose

/usr/share/brother/Printers/HLL2390DW/cupswrapper/brother-HLL2390DW-cups-en.ppd


Add Printer

You can do this from the commandline, or from the web ui.

Web-UI


- open http://localhost:631/admin/ :
  - Add Printer:  # auth as your user

# continue


CLI


Print queues are associated with your printer.
Consider naming them after the printer, (ex: epsonip110)

# find your printer
lsusb       # confirm printer detected
lpinfo -v   # find preinter URL (ex: usb://HP/DESKJET%20...)

# add your printer
# (cupsfilters in: /usr/share/ppd/cupsfilters/)
lpadmin -p ${queue} -E \
  -v "usb://HP/DESKJET%20..."       `# printer url` \
  -m drv:///hp-deskjet-940c.ppd.gz  `# cupsfilter`


Afterwards, you'll need to set the default printer and you may need to enable it.
(if you used the UI, queue may be set during setup, tab complete it)

# set default printer
lpoptions -d ${queue}  # can tab-complete queue

# may be unecessary
cupsenable ${queue}    # activate printer
cupsaccept ${queue}    # set printer accept jobs from queue


Usage

Printing

Locally

Your printer should be visible automatically from tools (ex. firefox)

lp file.txt  # print file

Network Printing

TODO:

I believe some of this setup can be abstracted by sharing the printer with samba.
I haven't looked into it yet.

NOTE:

In order to share a printer, when creating it, you must have clicked the radio box for Share Printer

You'll need to install cups on each client.

sudo pacman -S cups

You'll then need to add your printer over ipp

Administration: Add Printer
  Network Printers: Internet Printing Protocol (ipp)
  Connection:       ipp://x.x.x.x:631/printers/Brother_HL-L2390DW  # matches url for printer in UI
  Add Printer:      # anything
  Make:             Brother
  Model:            IPP Everywhere

If you're prompted for a password, you'll need to adjust cupsd.conf on your local machine.

Status/Debugging

lpstat -s            # status of default queue
lpstat -p ${queue}   # status of specific queue (tab complete queue names)

cupsenable ${queue}  # activate printer
cupsaccept ${queue}  # set printer accept jobs from queue

lpstat -s                           # printer status
lpr /usr/share/cups/data/testprint  # print testpage
lpr ${filepath}                      # filepath
ink                                 # print ink usage

Configuration

cupsd.conf

Listen 0.0.0.0:631    # cupsd listens on localhost/socket only by default
DefaultAuthType none  # disable user logins on admin

<Location />
  Allow from 192.168.2.0/24  # allow ip-range
  Allow All                  # allow from any ip-range
</Location>

Each block can have it's own configuration that overrides the defaults.

<Location /admin>
  AuthType Default
  Require user @SYSTEM
  ORDER deny, allow
</Location>

Troubleshooting

Jobs queued, but will not print

Try deleting and re-adding the printer.