about summary refs log tree commit diff
path: root/pkgs/profpatsch/read-qr-code.nix
blob: bc4684c1105fc683fc47b6515356375213fbee1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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";
  };
}