QR-codes

I wrote pair of scripts to tranfer small pieces of text information (e.g. URLs) from notebook to phone (Nokia N900) and vice versa.

qrcode - to make QR-code (using Google Chart API) and display it:

#!/usr/bin/python
import sys
import webbrowser
import urllib
if len(sys.argv) == 1:
  s = sys.stdin.read()
else:
  s = sys.argv[1]
webbrowser.open("http://chart.apis.google.com/chart?chs=300x300&cht=qr&chl=%s" % (urllib.quote(s, safe="")))

I put this script both on the phone and on the notebook.

Usage:

$ qrcode < file
$ qrcode text
$ qrcode
  text
  text2
  Ctrl-D

Reading of the QR-code - on the phone I use mBarCode.

On the notebook - qrread:

#!/bin/bash
trap 'xclip /tmp/qr -selection clipboard' 2
zbarcam --raw -q | tee /tmp/qr
# --nodisplay

I installed "zbar" program, for gentoo it is in "bircoph" overlay.

If you don't want to watch image from camera, you should uncomment "--nodisplay" parameter.

As soon as recognized text appears in console, you should press Ctrl-C, and it will be in clipboard. I transferred the source of qrcode from phone to notebook using this method, for example.

I will change scripts to not using Google (offline). UPD: Done

blog comments powered by Disqus