Skip to content

Instantly share code, notes, and snippets.

@shiona
Last active August 14, 2025 10:43
Show Gist options
  • Select an option

  • Save shiona/06ba20c123f317a371fd9d927c2f935d to your computer and use it in GitHub Desktop.

Select an option

Save shiona/06ba20c123f317a371fd9d927c2f935d to your computer and use it in GitHub Desktop.
Show clipboard content in a qr code.
#!/usr/bin/sh
# This version uses feh. Much cleaner.
# Fetch data, I prefer primary, but you can edit these to your liking.
if [ $XDG_SESSION_TYPE = "wayland" ]; then
data="${1:-$(wl-paste -p)}"
elif [ $XDG_SESSION_TYPE = "x11" ]; then
data="${1:-$(xclip -o)}"
fi
# If there's no data, exit
[ -e $data ] && exit 1
# I like to have some sort of border, so I use convert (from imagemagick)
qrencode -s 5 -o - "$data" | convert -bordercolor black -border 8 png:- png:- | feh -x --class floating -
# Assumes "for_window [class="floating"] floating enable" in the i3 config file
# or "for_window [class="floating"] floating enable" in sway config
#!/usr/bin/sh
# This version uses sxiv.
# Hard dependencies:
# qrencode
# xclip
# i3 specific stuff requires
# xdotool
# wmctrl
# i3-msg
data=$1
[[ -z $data ]] && data=$(xclip -o)
# Create temp image and open it "in the background" with sxiv
imagepath=$(mktemp /tmp/qr.XXXX)
imagedata=$(qrencode -s 5 -o $imagepath "$data")
# IF YOU ARE NOT USING i3, uncomment the two lines below and comment everything else below that
# sxiv "$imagepath"
# rm "$imagepath"
# Set the classname (not name as man page suggests) to a unique identifier
sxiv -N qrviewer $imagepath &
## Wait for the window to open and grab its window ID
winid=''
while : ; do
winid=$(xdotool search --classname qrviewer)
[[ -z "${winid}" ]] || break
done
# Focus the window we found
wmctrl -ia "${winid}"
# Make it float
i3-msg floating enable > /dev/null;
# Move it to the center for good measure
i3-msg move position center > /dev/null;
rm $imagepath
@shiona
Copy link
Author

shiona commented Aug 14, 2025

I finally needed this on wayland myself, so I added you fix. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment