Patch to make libinklevel work with a Canon i950 printer

This weekend, while cruising freshmeat.net, I happened upon libinklevel, from Markus Heinz. From the description:

Libinklevel is a library for checking the ink level of your printer on a system which runs Linux. It supports printers attached via parallel port or usb.

I downloaded and installed the latest versions of that and a complementary command-line tool called ink (uses libinklevel and is from the same author). No luck with my Canon i950 printer:

marc@tbird:~/sw/libinklevel-0.7.2$ sudo ink -p usb
ink v0.4.1 © 2007 Markus Heinz

Printer not supported.
Could not get ink level.

After a few minutes of glancing at the code, I was able to get it working. Here’s the patch. Now the output of the ink tool looks like this:

marc@tbird:~/sw/libinklevel-0.7.2$ sudo ink -p usb
ink v0.4.1 © 2007 Markus Heinz

Canon i950

Cyan:                          40%
Light Cyan:                   100%
Black:                         10%
Yellow:                        70%
Magenta:                       10%
Light Magenta:                100%

While I was modifying the code, I noticed that there was a #define constant called MAX\_NUMBER\_OF\_MODELS, that needed to be updated whenever one adds or removes printers to the existingPrinters array. This was a little cumbersome, so I modified the code to not need that. Here’s the patch.

I will of course send these patches to the author, Markus Heinz, so that the Canon i950 can work “out of the box” with the next version of libinklevel.

WordPress and DreamHost: Perfect Duo

2 thoughts on “Patch to make libinklevel work with a Canon i950 printer

Leave a Reply

Your email address will not be published. Required fields are marked *