On 19-08-09 17:52:05, Eric Smith wrote:
I'm setting up a turnkey system that uses a Zebra brand USB barcode printer. I need to use it without CUPS, directly printing from an application. I've verified that this works when my application writes to /dev/usb/lp0. I've had to either run the application as root or change the permissions on /dev/usb/lp0. I though I could solve this problem by using a udev rule to recognize the printer, create a symlink, and set the permissions. I created the following rule in /etc/udev/rules.d/99-zebra.rules.
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="0a5f", ATTRS{idProduct}=="011c", MODE="0666", SYMLINK+="zebra
This sort of works, but not in any useful way. It does recognize the printer, but instead of creating the symlink to /dev/usb/lp0 and changing the permission of that device file, it creates a symlink to e.g. /dev/bus/usb/001/002, and sets the permissions of that. However, I can't print to /dev/bus/usb/001/002 (or the symlink to that). Printing to /dev/usb/lp0 still works fine.
How do I write a udev rule that will set the permission of and symlink to /dev/usb/lp0 instead of the raw USB device?
I think you want to create a symlink from /dev/usb/lp0 to the new device, so instead of:
SYMLINK+="zebra
you want:
SYMLINK+="usb/lp0"
as on my system, /dev/cdrom is a symlink to /dev/sr0:
$ ll /dev/cdrom lrwxrwxrwx. 1 root root 3 Aug 9 12:48 /dev/cdrom -> sr0 $ ll /dev/sr0 brw-rw----+ 1 root cdrom 11, 0 Aug 9 12:48 /dev/sr0
You may wish to set a group (and if need be make one) and set mode 660, for a bit of security.
Note that I don't write UDEV rules myself; this is from looking around.