Friday, May 20, 2011

Linux USB Printer/Scanner Hacks.

I develop scanner/printer firmware. I develop under Linux.

Here are a few handy things I use to make my life easier.

Disable the Ubuntu “New Printer” dialog.
From Jeremy Ward, a coworker.

“One issue I was having was the printer driver install prompts displayed when plugging the dev board in/loading code on the dev board. I remember you mentioning that you had the same problem on Ubuntu. I was able to fix this issue by modifying the rules in /lib/udev/rules.d/70-printers.rules. I commented out all of the rules since that is what tells the system to launch the prompts. I don’t think there are any negative consequences from doing so.”

Allow user read/write to /dev/usb/lp*.
Add yourself to the ‘lp’ group with usermod. See usermod(8) man page.

Fedora : run system-config-users script (tested on FC14)
Ubuntu 11.04 : (from Desktop) System -> Administration -> Users and Groups

Allow user to scan without using root.
Either of the following methods should work. The following examples assume a USB VID of 0×8086 and USB PID of 0×1234.

From Eric Huang, a coworker.

- Add a new file called /etc/udev/rules.d/mrvl-printer.rules
- Add a line to the new file:
ATTRS{idVendor}==”8086” MODE:=”0666”

From David Poole.

- Edit /etc/udev/rules.d/40-libsane.d
- Add the following before the first ATTRS{idVendor}:
ATTRS{idVendor}==”8086″, ATTRS{idProduct}==”1234″, ENV{libsane_matched}=”yes”

I've also found being logged in to the console (the PC itself) allows me to scan on Fedora. There is some magic going on in udev where, if the user is on the console, access to the USB devices is allowed.