about summary refs log tree commit diff
path: root/pkgs/profpatsch/read-qr-code.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/profpatsch/read-qr-code.nix')
-rw-r--r--pkgs/profpatsch/read-qr-code.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/profpatsch/read-qr-code.nix b/pkgs/profpatsch/read-qr-code.nix
new file mode 100644
index 00000000..bc4684c1
--- /dev/null
+++ b/pkgs/profpatsch/read-qr-code.nix
@@ -0,0 +1,26 @@
+{ stdenv, writeExecline, getBins, zbar, libnotify, imagemagick }:
+
+let
+  bins = getBins zbar [ "zbarimg" ]
+      // getBins imagemagick [ "import" ]
+      // getBins libnotify [ "notify-send" ];
+
+  script = writeExecline "read-qr-code" {} [
+    "backtick" "-iE" "qrcontent" [
+      "pipeline" [
+        bins.import "png:-"
+      ]
+      bins.zbarimg
+        "-Sdisable"
+        "-Sqrcode.enable"
+        "--raw"
+        "-"
+    ]
+    bins.notify-send "$qrcontent"
+  ];
+
+in script // {
+  meta = {
+    description = "Capture a screenshot, then display the content of the QR code, if any";
+  };
+}