Quickly generate and decode QR codes in Linux terminals

Share on:

Overview

We need to do two things:

  1. Decode QR code on Linux screen and print the result on terminal

  2. Convert a string to QR code on terminal, and display the QR code in the terminal for scanning

Method

  • Generating QR code

    qrencode is a common CLI program for generating QR codes, found in many distribution repositories. It supports outputing QR code in terminal. (It also supports output to image files)

  • Decoding QR code

    This method is tested on X11

    1. Run a CLI screenshot program in terminal to get QR code image

      scrot is a CLI screenshot program that is available in many distribution repositories

    2. Pass the image to CLI program to decode the QR code.

      We use zbar to decode QR code and display results in terminal.

I've implemented above into a shell script:

  • Run this script in the terminal, and then rect-select the QR code on the screen with mouse to get the results.

  • Pass any string as an argument to this script to display the QR code on the screen terminal.

Script

https://github.com/garywill/qrshot

All articles are original (except for those specially claimed) and copyrighted. Copying without permission is forbidden.

Buy me a coffee

Your donation will be an impetus for me!