Question

What I need to do, is execute a python program/script in conjunction with user presses print, and not let the print job spool before this program quits.

Reason is that the print driver is not open source, and I need to change user settings (in this case a department id and password), that normally is per/user, but as this is a kiosk(different users with the same account) I need to make sure to reset, and prompt user before print jobs is spooled, so that different users won't pick up each others jobs.

I have created a program to handle the settings, I only need a way to start it, and not let the spool job start before the user has finished the program/settings.

I've tried to search/google this but can't really find an answer, do I need to spool the job through a cups filter first or if their is smarter way to handle this?

Was it helpful?

Solution

I found the perfect solution for my problem. tea4cups, it acts as wrapper for cups. And using a tea4cups prehook solved my issue.

I run into some issues though, so I note them here if someone is coming down the same road.

  1. tea4cups is based on python2 and I have python3 as standard library, this gave some unexpected errors like "wrong key" from cups log. To solve this I edited "/usr/lib/cups/backend/tea4cups" and changed the environment:

#! /usr/bin/env python

into:

#! /usr/bin/env python2

  1. My prehook needed to start a python program, as the that uses x display, and this was not working out of the box. And also this program needs to be started as the user who actually submit the print job. To get these two things work I had to write the prehook as follows:

prehook_popUp : su $TEAUSERNAME -c "DISPLAY=:0.0 python /usr/share/candepid/PopUp.py"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top