I forget which small use case I had, but I wanted to view the contents of a qr code. I don't really understand why I would be browsing a website, that wants me to open it up on a mobile browser to continue down an action path. I suppose it's because website/app authors can control a lot more, and read a lot more private info about the user, from a mobile device.
Well, here is my solution for Super+Shift+Q to let me select a region of the screen and pass it to a qr decoder.
files/2026/listings/scrot-qrdecode.sh (Source)
|
#!/bin/sh
|
|
# File: scrot-qrdecode.sh
|
|
# Location: https://bgstack15.ddns.net/blog
|
|
# Author: bgstack15
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Startdate: 2026-03-24-3 14:06
|
|
# Title: Decode qr Code from Screen
|
|
# Purpose: Grab rectangle from screen, and then display the decoded qr code contents, and offer to put in the clipboard.
|
|
# Project: scrot-qrdecode
|
|
# Usage:
|
|
# A keyboard shortcut, e.g., in ~/.fluxbox/keys
|
|
# Mod4 Shift Q :Exec scrot-qrdecode.sh
|
|
# To generate a qr code that can be scanned with this, run `qrencode "hello dolly" -t utf8 -o -`
|
|
# References:
|
|
# man: zbarimg, scrot, parcellite, xclip
|
|
# https://bbs.archlinux.org/viewtopic.php?id=190572
|
|
# Improve:
|
|
# Alternatives:
|
|
# xmessage: zenity or yad
|
|
# Dependencies:
|
|
# xclip, parcellite, xmessage, scrot zbarimg
|
|
|
|
result="$( scrot -s -l 'style=dash,width=1' - | zbarimg -S test-inverted - )"
|
|
# -e 'xclip -selection clipboard -t image/png -i $f'
|
|
|
|
xmessage -nearmouse -buttons "OK:1,Copy to clipboard:2" "${result}"
|
|
ec=$?
|
|
if test "${ec}" = "2" ;
|
|
then
|
|
result="$( printf '%s' "${result}" | sed -r -e "s/^QR-Code://;" )"
|
|
# Overkill, because xclip should count. But just to be sure, do it to parcellite directly.
|
|
echo "${result}" | xclip -selection clipboard -t text/plain -in
|
|
echo "${result}" | parcellite
|
|
fi
|
Here is a qrcode.

Comments