4

I'm looking for a simple way to read bar codes, data matrix and QR codes.

The scenario: I have it on my PC screen (website, photo, PDF, webcam), want the contained text

I'm on KDE, Kubuntu Precise, but other compatible reasonable non-kde solutions have a chance.

1

1 Answer 1

3

The idea is to use KSnapshot to pick the code from the screen, then run some utility on the captured image to decode it and finally place it in clipboard. Here is how:

install these utilities: xclip, zbarimg, dmtxread They can be found in the following packages:

$ sudo apt-get install xclip zbar-tools libdmtx-utils

These commands are used do the following:

  • xclip - insert text into the x clipboard
  • zbarimg - decodes bar code and QR codes to text
  • dmtxread - decodes data matrix codes

Create an executable bash file with this content:

#!/bin/bash
(zbarimg -q --raw $@ || dmtxread $@) | xclip -i

Save it in your home bin folder: ~/bin/codetoxclip

To make the file executable, run:

$ chmod -a+x ~/bin/codetoxclip

Now you'll want to test this script with some pictures first:

$ ~/bin/codetoxclip MyQR.png
$ xclip -o

You should see the decoded text on the console

Now go open your KSnapshot (should be under the print screen key), take a rectangular snap of some code (higher resolution is better, use zoom when necessary) and then click [Send to...] / Other application...

Here in the dialog, locate the script you created (~/bin/codetoxclip). It is handy to tick the "Remember application association..." checkbox so you don't have to do this step again. Next time you'll pick the script from the [Send to...] menu.

And that's it. Your code should be decoded to your clipboard, paste it wherever you feel like!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .