‹ back home

Quickly render the Clipboard as a QR code

2024-08-08 #clipboard #desktop #qr

I often want to copy URLs or text or other data from my laptop/desktop on a phone. Sometimes it’s my own phone, sometimes it’s someone else’s phone, and sometimes it’s a phone that isn’t even set up yet.

My solution works as follows:

This is convenient and globally accessible. It requires not connectivity between the devices; only line of sight.

Implementation

I created the following desktop entry in ~/.local/share/applications/clip2qr.desktop so it shows up in my launcher, fuzzel:

[Desktop Entry]
Version=1.0
Name=QR code for CLIPBOARD selection
TryExec=qrencode
Exec=sh -c "wl-paste | qrencode -s 30 -o - | imv -"
Icon=terminal
Keywords=qr;clipboard;selection
Type=Application
Terminal=false

This will pipe the clipboard into qrencode using wl-paste, and then render the image using imv. I can then scan it on the phone.

My launcher does fuzzy matching, so just typing qr shows my entry shows up as the first result. The whole sequence of keys is Super+d q r Return 1.

Dependencies

The necessary software can be installed on Alpine Linux with apk add wl-clipboard libqrencode-tools imv.


  1. Super+d is my mapping to open the launcher. ↩︎

Have comments or want to discuss this topic?
Send an email to ~whynothugo/public-inbox@lists.sr.ht (mailing list etiquette)

— § —