Skip to content

Instantly share code, notes, and snippets.

@drdaeman
Created August 24, 2012 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drdaeman/3455407 to your computer and use it in GitHub Desktop.
Save drdaeman/3455407 to your computer and use it in GitHub Desktop.
Simple CUPS backend wrapper for Canon LBP-810 and LBP-1120 FOSS driver
#!/bin/sh
# What's this
# -----------
# CUPS backend wrapper for Canon LBP-810 and LBP-1120 FOSS driver.
# Works for me with LBP-1120 on Ubuntu 12.04.
#
# Because I don't want a kludge with dummy serial:/dev/ttyS0 backend,
# as everyone on the 'net seem to suggest. That never worked for me.
# Nor I want to use Canon proprietary ccpd daemon, which frequently
# just fails to talk to the printer for unknown reason.
#
# Yes, this is a hack, too. Maybe I'll patch capt (and its PPD) later,
# to make things straight. Drop me a note if you already did. I'm lazy.
#
# Installation/usage
# ------------------
# 1. Install capt binary from http://www.boichat.ch/nicolas/capt/
# Specify path to it below (in gs pipe near the end), if necessary.
#
# 2. Put this script to /usr/lib/cups/backend.
# Don't forget to chmod +x capt.
#
# 3. Ensure usblp module is not blacklisted and you have /dev/usb/lp*
# No need to change permissions on device files, this script will be
# ran as "lp" user and group, which should already have access to it.
#
# 4. Add "CAPT printer on ..." with driver "Generic PostScript Printer"
# (NOT the "Canon LBP-810 Foomatic/capt")
#
# lpadmin -p LASER-SHOT-LBP-1120 \
# -m "Generic PostScript Printer" \
# -v capt:/dev/usb/lp0 -E'
#
# should hopefully do the job, although I've just edited autodetected
# USB printer using the CUPS web interface at http://localhost:631/admin/.
#
# 5. Things should work. Occasionally, they don't and driver's stuck,
# but power-cycling the printer seem to help.
#
if test "$#" = "0"; then
for idx in seq 0 9; do
DEVICE="/dev/usb/lp$idx"
if test -w "$DEVICE"; then
echo "direct capt:$DEVICE \"Unknown\" \"CAPT printer on $DEVICE\""
fi
done
exit 0
fi
if test -n "$6"; then
exec <"$6"
fi
DEVICE=$(echo "$DEVICE_URI" | cut -c6-)
if test ! -w "$DEVICE"; then
if test ! -e "$DEVICE"; then
echo "ERROR: no write permissions on $DEVICE"
else
echo "ERROR: device $DEVICE does not exists"
fi
exit 1
fi
echo "INFO: sending data to $DEVICE" 1>&2
gs -q -dNOPAUSE -dPARANOIDSAFER -dBATCH -r600x600 -sDEVICE=pbmraw -sOutputFile="|capt 1>/tmp/capt.log" -
echo 'INFO:' 1>&2
exit 0
@josla972
Copy link

Thank you very much. It works perfectly (using LBP-1120).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment