Skip to content

Instantly share code, notes, and snippets.

@adsr
Created August 20, 2025 15:12
Show Gist options
  • Select an option

  • Save adsr/b3a696deea9730a12c5db743940f651f to your computer and use it in GitHub Desktop.

Select an option

Save adsr/b3a696deea9730a12c5db743940f651f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
cleanup() {
test -n "$tmpf" && rm -f "$tmpf"
}
main() {
trap cleanup EXIT
tmpf="$(mktemp --suffix .png)"
while true; do
ffmpeg -y -f v4l2 -video_size 1280x720 -i /dev/video0 -update 1 -frames:v 1 "$tmpf" &>/dev/null
out=$(ZXingReader -format QRCode -bytes "$tmpf" || true)
test -n "$out" && xclip -sel c <<<"$out" && echo Copied && exit
sleep 1
done
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment