# Making a library



We (my wife and I) have a lot of books, currently some 637...

    $ sqlite3 biblio.db 'select count(*) from books' 
    637

But we seem to loose books occasionally because we lend them to people
and forget about it. So Linux (and Perl) to the rescue. I already 
[own a bar code reader](/2008/march/08/archiving_books/index.html)
to read the ISBN number of books and then I use Google to give
the author, genre, etc. (fully automated of course).

To keep track of what we lend to people 
I want to use a piece of paper (don't know the right English term
for this) to be put in the book. Every time we lend the book to
someone we *take out the paper* and *write the person's name on it*.
Just as in a real library, but more manual.

So now I want to print labels for our books and I
need some paper on which I can sticker these labels.

First things first. So I've bought a
[Dymo](http://global.dymo.com) 400 label printer. Which
believe it or not just works **out of the box** on Ubuntu Jaunty. 

> Where are the go'old days when this kind of stuff took weeks??!

# What next
Plug the label printer in a USB port, `apt-get install cupsys`, 
go to `localhost:631`, configure the label writer. Enter your
user name and password when it asks for it and you are done.

The only extra thing I needed to do was to configure it to
always print in `landscape`:

    $ lpoptions -o landscape

# Printing the labels
Printing with `lpr` now works 100% correct. So now I just need to format it so that
it looks nice.

So I wrote a small Perl utility that transforms this (which is the
standard output of `sqlite3`)

    662|9780000000205|The Computer Revolution|Nigel
    Hawkes|computer|1971|1221413260|

to this

    The Computer Revolution
       Nigel Hawkes

       COMPUTER

    ISBN: 9-780000-000205   1971

Which *just* fits on the label. 

Hopefully this will keep us from loosing any books from now on.


