# notify me when a command is finished
# todo : secret managment is shit
{
  config,
  pkgs,
  lib,
  ...
}:
with lib;
{
  options.components.gui.noti.enable = mkOption {
    type = lib.types.bool;
    default = config.components.gui.enable;
  };

  # todo : put this in `/homes`
  config = mkIf (config.components.gui.noti.enable) {

    clan.core.facts.services.noti = {
      secret."noti.yaml" = { };
      generator = {
        prompt = "noti.yaml";
        path = with pkgs; [ coreutils ];
        script = ''
          echo "$prompt_value" > "$secrets"/noti.yaml
        '';
      };
    };

    systemd.tmpfiles.settings.noti = {
      # don't like to use a non tmpfs here, but does not work another way
      "${config.users.users.mainUser.home}/.config/noti/noti.yaml"."C+" = {
        user = config.users.users.mainUser.name;
        group = config.users.users.mainUser.group;
        mode = "400";
        argument = config.clan.core.facts.services.noti.secret."noti.yaml".path;
      };
    };

    #    sops.secrets.pushover_user_key = { };
    #    sops.secrets.pushover_api_key = { };
    #    sops.templates."noti.yaml".owner = config.users.users.mainUser.name;
    #    sops.templates."noti.yaml".group = config.users.users.mainUser.group;
    #    sops.templates."noti.yaml".content = ''
    #      pushover:
    #        userKey: ${config.sops.placeholder.pushover_user_key}
    #        apiToken: ${config.sops.placeholder.pushover_api_key}
    #    '';

    home-manager.users.mainUser = {
      programs.noti.enable = true;
      #      xdg.configFile."noti/noti.yaml".target = "/run/facts/mainUser.noti.yaml";
    };

  };
}