Run command before and after printing with CUPS?

6,045

My suggestion is to use tea4cups.

tea4cups serves as a generic wrapper around any standard CUPS backend. It allows you to configure any command to run before and after sending the job off via the real backend.

tea4cups specifically allows (any number of) commands to be run before the job is sent off: prehooks. A prehook command which exits -1 can cancel the job.

tea4cups also allows (any number of) commands to be run after the job is sent off: posthooks (unless a prehook with exit -1 cancelled the job).

Prehooks can send data to the posthooks through pipes.

tea4cups can also run filters (which may modify the print data before sending them off to the real printer through the real backend).

From now on, only your own creativity is a limit to what you can do with this framework.

Share:
6,045

Related videos on Youtube

leto
Author by

leto

Updated on September 17, 2022

Comments

  • leto
    leto almost 2 years

    Problem

    • A CUPS-Printer needs to be turned on automatically as soon as there are unfulfilled jobs

    Tried Solutions

    • A shell script watches the queue on the server (lpstat -o) and turn on the printer when there is a job. If the queue is empty for 10 minutes it turns the printer off.
    Original Question:

    this is a home setup. A central printer server (Linux) manages the queue, a HP 2430DTN is attached to it via 100Mbit/sec Ethernet. The printer is hooked up to a managable power source. A shell script watches the queue on the server (lpstat -o) and turn on the printer when there is a job. If the queue is empty for 10 minutes it turns the printer off.

    Now this setup messes up, stops the printer etc. after a couple of weeks and is in general "not so reliable". I now know how to change the stop-printer thing, but:

    Is there a way to run my turn printer on script and turn printer off script directly from cups without watching the queue? That would be so cool!

  • Leandro
    Leandro about 6 years
    Tea4Cups seem to be dead. Is there any successor or equivalent free software system, @kurt-pfeifle?