There's a qrcode python package:
pip install qrcode
Which provides a command-line program qr
.
It prints ascii-art QR codes:
This is made using the block elements part of unicode. I fondly remember old MS-DOS programs which made great use of block elements and box drawing.
$ echo qr | qr
█████████████████████████████
█████████████████████████████
████ ▄▄▄▄▄ █▄ ▀██ ▄▄▄▄▄ ████
████ █ █ █▀▄▀▀ █ █ █ ████
████ █▄▄▄█ █ ▀▀▀▄█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀ ▀ █▄▄▄▄▄▄▄████
████▄█▀▀▄█▄ █▄ ▀▄▄ ▄▄▀█▄████
████▀▀█▀▄▀▄█▄▀ ▄█▀ ▄ ▄ █████
████▄▄▄▄█▄▄█ ██ ███▄▄▄████
████ ▄▄▄▄▄ █▄ █▀ ▄█▀█ ▄ ▀████
████ █ █ █▄ ▀ ▀█▄ ▄▀▄ ████
████ █▄▄▄█ ███ ▄█▀ ▄ ▄ ██████
████▄▄▄▄▄▄▄█▄███▄▄▄███▄█▄████
█████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The colors in this example are inverted, as it expects a light-on-dark terminal color scheme (which this blog isn't).
Make a QR code which contains the image of a QR code:
$ echo qr | qr | qr
I cheated slightly here by alias qr='qr --error-correction=L --optimize=0'
to make the QR code smaller.
$ echo qr | qr | qr | qr > qr-cubed.png
I have taken this too far.
Bonus: The QR Clock:
while sleep 1; do
date --rfc-3339=seconds \
| qr --optimize 0 > /tmp/a.png \
&& clear \
&& COLUMNS=300 img2txt --width=90 /tmp/a.png;
done