about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--machines/profpatsch/shiki.nix1
-rw-r--r--pkgs/profpatsch/default.nix3
-rw-r--r--pkgs/profpatsch/read-qr-code.nix26
3 files changed, 30 insertions, 0 deletions
diff --git a/machines/profpatsch/shiki.nix b/machines/profpatsch/shiki.nix
index 939d7ea0..a5dba1da 100644
--- a/machines/profpatsch/shiki.nix
+++ b/machines/profpatsch/shiki.nix
@@ -244,6 +244,7 @@ in {
         display-infos  # show time & battery
         di-notify      # same, but pipe to libnotify
         show-qr-code   # display a QR code
+        read-qr-code   # read a QR code on the screen
         backlight      # adjust laptop backlight
         sfttime        # geek time
       ];
diff --git a/pkgs/profpatsch/default.nix b/pkgs/profpatsch/default.nix
index f05545bf..10936366 100644
--- a/pkgs/profpatsch/default.nix
+++ b/pkgs/profpatsch/default.nix
@@ -133,6 +133,9 @@ in rec {
   };
   sfttime = callPackage ./sfttime {};
   show-qr-code = callPackage ./show-qr-code {};
+  read-qr-code = callPackage ./read-qr-code.nix {
+    inherit writeExecline getBins;
+  };
   warpspeed = callPackage ./warpspeed {
     inherit (pkgs.haskellPackages) ghcWithPackages;
   };
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";
+  };
+}