Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to setup a Class in CUPS with 2 printers, one colour, one black & white, then route jobs to each printer based off the document data - Jobs with colour to the colour printer, and anything without colour to the B&W printer.
Or any way to achieve the same thing, doesn't have to be through a class. I'm happy to have just the 2 printers setup, but if someone prints a B&W document to the colour printer, then have it forcefully re-routed to the B&W printer.
We currently have an Oki C7350 Colour Laser which is costing a fortune in consumables and repairs, and I want to replace with a B&W HP (something like a HP 4250), and a small colour laser, then get CUPS to do some smart stuff
Everything already runs through a CUPS server with Samba, so there's no problem there, just need to figure out the smart part!
I believe that both printers are postscript so this might work for you. You can create a virtual printer share in samba that executes a scipt to search the spooled file for the lack of postscript color commands. A simple bash if statement can be used to send the job to the correct printer via the lpr command and then delete the spool file. The /usr/local/bin/printselect bash script does the actual searching and printing.
example:
[someprinter]
comment = Auto printer
printing = LPRNG
path = /var/spool/samba
printable = yes
# Parameters below: spool file name, job name, user name, user home dir
print command = /usr/local/bin/printselect %s %u %H "%J"
Does anyone know what the Postscript colour commands are?
The script would be something like this...?
Code:
#!/bin/bash
COLOURJOB=`grep %1 'color=yes'`
if [ -z "$COLOURJOB" ] ; then
lpr -Pbwprinter %1
else
lpr -Pcolourprinter %1
fi
(Replace 'color=yes' with whatever the PS colour command is)
Well, it’ll be a little more complicated than this. You see, the commands such as setrgbcolor or setcmykcolor can be used to set the color to a “color” or a shade of gray (which is technically a color). Moreover, because postscript is a programming language, you can’t just grep for the three tokens textually preceding a “setrgbcolor” (since the actual “parameter” could have been manipulated prior to being received by setrgbcolor). E.g.,
Code:
%!
0 0 0 setrgbcolor % sets color to black
0 0 moveto 1 0 lineto stroke % this line is black
0 0 1 setrgbcolor % sets color to blue
0 0 moveto 0 1 lineto stroke % this line is blue
0 0 -1 1 add setrgbcolor % also sets color to black
0 1 moveto 1 1 lineto stroke % this line is black
So you’ll have to have some kind of interpreter do this for you. You might take a look at some of the “devices” of ghostscript. This is what a sample script might look like in my mind:
Code:
#!/bin/bash
#If $1 is the name of a postscript file, this
#script will determine whether the file is suitable
#for printing as color or grayscale
GRAYED="$1.grayed.ps"
gs -q -sDEVICE=psgray -sOutputFile=${GRAYED} ${1}
if [ -z "$(diff ${1} ${GRAYED})" ] ; then
echo "$1 is grayscale"
else
echo "$1 is color"
fi
Obviously, there should be a better way to determine the changes, but that’s the idea.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.