{ pkgs, config, lib, ... }:
with lib;
let

  # desktop file
  # ------------
  # makes it possible to be used by other programs
  desktopFile = name: bin:
    pkgs.writeTextFile {
      name = "${name}.desktop";
      destination = "/share/applications/${name}.desktop";
      text = ''
        [Desktop Entry]
        Categories=Application;Utility;
        Comment=password dialog
        Encoding=UTF-8
        Exec=${bin}
        Icon=gnome-lockscreen
        Name=${name}
        Terminal=false
        Type=Application
      '';
    };

in
{
  options.components.gui.pass.enable = mkOption {
    type = lib.types.bool;
    default = config.components.gui.enable;
  };

  config = mkIf (config.components.gui.pass.enable) {

    environment.systemPackages = [
      (pkgs.pass.withExtensions (ext: [ ext.pass-otp ]))
      # todo : use upstream desktop file creator
      (desktopFile "passmenu" "${pkgs.pass.withExtensions (ext: [ext.pass-otp])}/bin/passmenu --type -l 10")

      pkgs.otpmenu

      # todo ein script machen was hier tut
      # zbarimg -q --raw 2018-12-18-114509.png   | pass otp insert mindcurv/cloudamqp/otp
      pkgs.zbar
    ];
  };
}