qrscan: use new one shot scanning mode

This commit is contained in:
tv 2022-03-22 19:34:57 +01:00
parent 44ec31fe02
commit 1fc622cd08

View File

@ -1,27 +1,7 @@
{ coreutils, gnused, writeDashBin, zbar }:
{ pkgs }:
writeDashBin "qrscan" ''
pkgs.writeDashBin "qrscan" ''
set -efu
tmpdir=$(${coreutils}/bin/mktemp --tmpdir -d qrscan.XXXXXXXX)
codefile=$tmpdir/code
cleanup() {
${coreutils}/bin/rm "$codefile"
${coreutils}/bin/rmdir "$tmpdir"
}
${coreutils}/bin/mkfifo "$codefile"
${zbar}/bin/zbarcam > "$codefile" &
zbarcampid=$!
exec < "$codefile"
while read -r code; do
code=$(printf %s "$code" | ${gnused}/bin/sed -n 's/^QR-Code://p')
if test -n "$code"; then
${coreutils}/bin/kill "$zbarcampid"
echo "$code"
fi
done
${pkgs.zbar}/bin/zbarcam -1 | ${pkgs.gnused}/bin/sed -n 's/^QR-Code://p'
''