用户按下print时运行脚本,并且在脚本结束之前不启动假脱机(Linux,cups) [英] Run a script when user press print, and not start spooling before script ends (linux, cups)
问题描述
我需要做的是结合用户按下print命令执行一个python程序/脚本,并且在该程序退出之前不要让打印作业假脱机.
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.
原因是打印驱动程序不是开源的,我需要更改用户设置(在本例中为部门ID和密码),该设置通常是每个用户的身份,但是这是一个信息亭(具有同一帐户),我需要确保重置,并在后台处理打印作业之前提示用户,以便不同的用户不会互相接替对方的工作.
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?
推荐答案
我找到了解决我问题的完美解决方案. tea4cups ,它可以作为杯子的包装纸. 并使用tea4cups预钩解决了我的问题.
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基于python2,我将python3作为标准库,这产生了一些意外的错误,例如cups日志中的错误密钥". 为了解决这个问题,我编辑了"/usr/lib/cups/backend/tea4cups"并更改了环境:
- 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
进入:
#! /usr/bin/env python2
- 我的预钩需要启动一个python程序,因为该程序使用x显示功能,并且开箱即用.此外,还需要以实际提交打印作业的用户身份启动该程序.为了使这两件事都起作用,我必须编写如下的预钩:
prehook_popUp:su $ TEAUSERNAME -c"DISPLAY =:0.0 python/usr/share/candepid/PopUp.py"
这篇关于用户按下print时运行脚本,并且在脚本结束之前不启动假脱机(Linux,cups)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!