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.
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: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.I dunno if it's what you want to do but if you're trying to disable the keyboard emulation that output barcode sequences in stdin/console just try this:
Create a file "/etc/udev/rules.d/10-barcode.rules"
Of course, replace xxxx and yyyy with your own vendor_id and product_id, and reload the rules with "udevadm control --reload"
This will remove the event/input part that is emulating keyboard and keep the hidraw part to access barcode scans. The second line just create a /dev/barcode device to read linked to the hidraw
Just open that file in your code to read strings sent by the barcode
For what it's worth and for anyone with a similar problem finding this;
I don't know if it's possible to disable a "keyboard", but since the system is headless anyway, you can just run a service to handle the input in TTY1, replacing the normal login prompt. You can still login normally via ssh or any other TTY, but on boot, by default, the barcode reader input is handled properly without additional action.
A nice bonus is to run all of that inside a screen session, so you can connect to it using ssh.
For instructions, check out my answer on SU here.