I am looking forward to buy a barcode scanner for a project. This project is a web application running as a web server on the local computer, and a browser on that same machine for the client-side. The barcode scanner would be attached to that machine.
It seems a lot USB barcode scanners emulate a keyboard, however I would like to differentiate regular keyboard input from the barcode scanner data. How could I achieve that ?
Getting the barcode data on the server-side
An interesting configuration for me would be to simply fetch the data from the barcode scanner from my application (I think this can be done by reading from /dev/input/by-path/pci-XXX-usb-XXX-kbd
), and disable that device in Xorg (since the /etc/X11/Xorg.conf
file is mostly bypassed in recent ubuntu versions, I don't know how to do that).
Note that I would like if possible to trap input from the barcode scanner while my application doesn't have focus (it's the server part of a web application, so it's not even an Xorg application), so I do need to prevent Xorg from sending the events to the focused application.
Getting the barcode data on the client-side
Otherwise, I could map a fake keyboard layout on the barcode scanner (eg. mapping the digits to obscure utf-8 characters) but keep the regular layout for the keyboard, using this technique detailed on Super User . Then I would know when the barcode scanner is used because I would recieve weird digits on the client side (a web page).