Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux, reading from barcode scanner

I have barcode scanner, attached to Linux computer via USB. The scanner emulates a keyboard device.

I have to write a program that to read the scanned barcodes and process them. The program runs on background as a service and should read the barcode scanner regardless of the current X focus.

How this can be made in Linux?

Some lower level solution/explanation is preferred.

like image 658
johnfound Avatar asked Feb 06 '17 12:02

johnfound


1 Answers

It sounds like you want to capture the data from a specified device, In which case the method described in this post should help:

(EDIT: original link dead, Archive link provided)

https://web.archive.org/web/20190101053530/http://www.thelinuxdaily.com/2010/05/grab-raw-keyboard-input-from-event-device-node-devinputevent/

That will listen out for keyboard events stemming from only the specified source.

A word of caution though, as far as I know, that won't stop it from propagating to whatever your current window focus is.

like image 158
Minothor Avatar answered Oct 03 '22 07:10

Minothor