Skip to main content

Qutebrowser and URLs as QR-codes

Implementing a qr-code for a visited URL in Qutebrowser

When I have been to the 35c3 in Leipzig I saw a pretty firefox addon that became very handy when we wanted to share the URL to a freshly created pad. It was FxQRL a Firefox add-on that turns your URLs into QR code images without the need of a network connection. Everyone of us could then scan this code with our mobile phones, and we were done.

I don't use Firefox but it immediatly appeared to me that this function could be copied with qutebrowser without any problems

Qutebrowser is a browser based (by default) on QTWebEngine, and is very easily extendable via userscripts. To get me the same functionality as the FxQRL addon of Firefox has, I just need to call such a userscript, and to make it even easier bind that call to a key I dont need otherwise. I did that with this command:

:bind q spawn --userscript link2qr

That will call a userscript named 'link2qr' everytime I press 'q.' The only thing that was left to do was creating that userscript. Qutebrowser is very relaxed, in what it calls a userscript. It just has to be executable and live in the directory reserved for those scripts. So my script just looks like this:

#!/bin/bash

qrencode -o - $QUTE_URL | feh -

In this script two tools are used:

  1. qrencode, which encodes a given string into a QR-code, and pipes it to
  2. feh, which then shows it on the screen

For an example page, it looks like this:

A screenshot with qutebrowser showing a random page in the left 80% of the screen and a black window with an qr-code in the right 20% of the screen

So now I have the same functionality in my browser, without relying on code that someone else has written.

2019-01-01