2019-01-01T19:56:29+01:00

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:

nil

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


Andy Drop

I like it, when I see the intentions of a code author, and i like to see it written down in remark lines. Why didn't someone do that with the world. It would be far easier to understand. So I started to document my world wherever I see the need to do so. In text. With Emacs Org mode. I want to share this world with you.


Categories

  • Emacs logoEmacs
    The OS-like text editor
  • Org mode logoOrg mode
    Emacs built-in mode for organizing everything
  • Plaintext logoPlaintext
    Using plain text for everything