Jabber to Dot Matrix

So I had a dot matrix printer available. A Panasonic KX-P1124 and it worked out of the box. Even with CUPS via a USB adapter! That was a bit too easy.

That's when I started to think about what one could print on one of those loud slow printers and decided to put the printer on a FreeBSD 7 miniITX machine in the basement which runs a jabber bot which then sends the messages through LPR/LPD.

I based the bot on Jabberbot, which made it very easy to get everything running in under 40 lines. If you send help to the bot it will tell you that it can give you the host's local time with time, authorize you so that you can see when it's on or offline with hi and finally send will pipe everything that follows to the printer. Actually, it's a 400 character limit and is piped through a simple LPR filter, namely:

tr -d "\f" && fmt -w 70 && exit 0

This removes the annoying form feed character which otherwise causes the page to be advanced fully, which just wastes a lot of paper for this thing. Then it forwards everything nicely formatted. Activating the filter is pretty easy with a note in /etc/printcap where the printer is defined, mine looks like this:

lp|local printer:
:sh:\
:lp=/dev/ulpt0:sd=/var/spool/output/lpd:if=/etc/filters/filter1:lf=/var/log/lpd-errs:

I'm not quite sure why you might want to sent short notices to our basement, but, well, you can now! The bot is dotmatrix@jabber.org. And only sending during daylight hours (CET) would be appreciated. (Yes, I know, I really should make the bot check that.)

To make it look a bit nicer I added a header with a timestamp for every message at the beginning. The resulting messages feel a bit like a telegram crossed with a stock ticker.