Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What i have:

  • Linux machine (debian stable) without monitor, keyboard, no X running
  • USB-device which acts like an USB-keyboard (like many barcode-readers [1])

What i (don't) want:

  • I want to use this device only for one specific application.
  • I don't want to have this device interfere with e.g. the login process after booting or anything else - except the one application.
  • In any way, i want to be able to plug in a plain old USB keyboard an use it as such - independent of how many other USB-devices like mentioned above may be connected or not.

What i (don't) know:

  • I found some example codes, about how to read directly from the event devices and can use this in my application, if needed.
  • I don't know, how to disable a specific keyboard for the whole system except this specific application? Is this even possible?

Thanks for any hints ... !

[1] When the device reads a barcode, it's sends the detected code as single key presses and commits with return.

share|improve this question
    
Perhaps there is a better word instead of "bind" which reveals better search results? Any hints appreciated! –  m.sr May 2 '12 at 16:49
    
I know this is an old thread, but I found the answer here: stackoverflow.com/questions/1698423 –  user185406 Aug 13 '13 at 7:13
    
@McLovin ... thanks a lot, exactly what i was searching for! –  m.sr Sep 21 '13 at 12:12

1 Answer 1

A challenging and interesting question!

I think udev might be capable of doing just that. Create a file /etc/udev/rules.d/99-barcode-reader.rules and put there something similar to this:

ACTIONS!="add", GOTO="barcode_end"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="dead", ATTRS{idProduct}=="beef", PROGRAM="/bin/sh -c 'logger -p user.info Hey, I see a new device $env{BUSNUM} $env{DEVNUM}'", RUN+="/bin/sh -c '/usr/local/bin/your_barcode_application &'"
LABEL="barcode_end"

Replace "dead" and "beef" with the values you get for idVendor and idProduct with lsusb.

Restart udevd or simply your server, and see what happens.

share|improve this answer
    
Thank you for your input. Sadly there is no way to disable a keyboard device with udev i know of. Your example udev-rule sure helps discovering the right device but doesn't help to "bind" my device to a distinct application. So the input device is still cluttering the login-prompt of the current console for example ... –  m.sr May 2 '12 at 16:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.