python qr

This commit is contained in:
elwrcl committed 2026-08-27 21:17:32 +03:00
1 parent f379e7368e
commit bc367e4f2e
1 file changed
+24 -17
+24 -17
View File
@@ -65,24 +65,17 @@
'';
};
drmPanicDecode = pkgs.writeShellApplication {
name = "drm-panic-decode";
runtimeInputs = [
pkgs.zbar
pkgs.python3
];
text = ''
if [ "$#" -lt 1 ]; then
echo "usage: drm-panic-decode <panic-screen-photo>" >&2
exit 1
fi
panicInflate = pkgs.writers.writePython3Bin "drm-panic-inflate" {
flakeIgnore = [ "E501" ];
} ''
import sys
import zlib
zbarimg --raw -q --oneshot -Sbinary "$1" | python3 -c '
import sys, zlib
data = sys.stdin.buffer.read()
if not data:
sys.exit("Could not read QR: try taking a clearer/straighter photo")
# Try raw deflate, zlib-wrapped, and gzip variants in order
sys.exit("Could not read QR: try a clearer, straighter photo")
# Try raw deflate, then zlib-wrapped, then gzip.
for wbits in (-15, 15, 47):
try:
sys.stdout.buffer.write(zlib.decompress(data, wbits))
@@ -90,9 +83,23 @@ for wbits in (-15, 15, 47):
except zlib.error:
continue
else:
sys.stderr.write("warning: could not decompress, printing raw data\n")
sys.stderr.write("warning: could not decompress, printing raw bytes\n")
sys.stdout.buffer.write(data)
'
'';
drmPanicDecode = pkgs.writeShellApplication {
name = "drm-panic-decode";
runtimeInputs = [
pkgs.zbar
panicInflate
];
text = ''
if [ "$#" -lt 1 ]; then
echo "usage: drm-panic-decode <panic-screen-photo>" >&2
exit 1
fi
zbarimg --raw -q --oneshot -Sbinary "$1" | drm-panic-inflate
'';
};
in