You are not logged in.

#1 2010-05-25 02:57:04

whacath
Member
Registered: 2009-05-26
Posts: 283

watch-directory for your printer?

I just discovered flexget a program that can (if i understand i correctly) download something, for example xkcd automatically every time a new issue comes out and put the comic in a directory.

Now i got an idea about this. A watch directory for your printer. Everytime something is put in this watch directory it get printed out.

Anyone of you guys aware of such a utility capable of this or want to script one? smile

Think about the possibilities! everytime a new issue of xkcd or ALM get published it is automatically printed out for you. smile

I would buy a dedicated toilet-printer ;D

Last edited by whacath (2010-05-25 03:00:43)

Offline

#2 2010-05-25 03:24:25

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: watch-directory for your printer?

Simple.

Watch the dir with inotify. Whenever a new file is created, print it.

I have no printer I can use for testing though.

@whacath: tjockis?

Offline

#3 2010-05-25 03:30:10

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: watch-directory for your printer?

#!/bin/sh

watchdir=/path/to/watchdir

inotifywait -qm --event CREATE --format %f "$watchdir" | while read file; do
  lpr "$watchdir/$file"
done

Of course you'd need some better logic than just throwing everything directly at lpr, but inotify is the way to go and it doesn't need to be much more complicated than this.

Offline

#4 2010-05-26 21:32:58

whacath
Member
Registered: 2009-05-26
Posts: 283

Re: watch-directory for your printer?

Cool! Thanks guys! smile

@dmz: du ja!

Offline

Board footer

Powered by FluxBB