How to write a (pre-)filter
Goffioul Michael
goffioul at imec.be
Fri Mar 16 09:34:29 CET 2007
> Hi,
>
> I'm trying to get the KDE printing system to use a hand-made
> script as a virtual printer, but I can't figure out how.
>
> The complete task is: I want to print documents from my
> laptop on my maths department's printers.
>
> The situation: I use a laptop with Kubuntu (Edgy), hooking it
> up to the math department's network, which consists of Sun
> workstations. I have a login for those Suns. Due to
> historical reasons, it is not possible to send a print job to
> the department's print server from anywhere else than these Suns.
>
> Work-around at the moment: I have written a script, which
> automates the process of taking a .ps file (or converting
> .pdf and .dvi to .ps), copying it to a temporary file on a
> Sun via scp, logging in on the Sun, issueing the print
> command, and finally deleting the temporary file. This script
> needs a .ps or .pdf or .dvi file as an argument, i.e. it
> can't just read the data to be printed from stdin. This
> script is called "miprint".
>
> What I would like: Calling the miprint script from the
> command line is quite tedious, so it would be nice to have a
> KDE printer that does the same: Print to a temp file, and
> then get the tempfile printed on the Suns.
>
> I've tried to solve this problem by defining a "special
> printer" with a filter filter, but how does this exactly
> work? Is a filter the right tool to print a document to a
> temporary .ps file, and then give this temp file to a script?
> If yes, how does the syntax work, e.g. what exactly is "%in"
> (input file? ps made from input file? data stream?), how is
> it connected with "%filterinput"
> and what is this "pipe" thing one can also define in this
> context? I've looked at the XML files of the pre-defined
> filters but they didn't help too much.
>
> If a filter is the wrong approach anyway, what would be the right one?
You don't need a filter for this. If your script can be called
as simply as "miprint file_to_print", then create a pseudo/special
printer and define its command to "miprint %in". The script will
be fed with a temporary postscript file, kdeprint will take care
of the temporary file creation and removal.
> Anyway, when KDEPrint prints something for e.g. user "anna", with what
> user ID is this done? (This could be important for things like reading
> ssh keys etc.)
Scripts associated with pseudo printers are executed in the user
space (they are independent of CUPS); more specifically within the
kded daemon. So the script is executed with the current user ID.
Michael.
More information about the kde-print
mailing list