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.
- 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
- 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"