{ config, lib, pkgs, inputs, ... }:

with lib;
let
  cfg = config.samfelag.modules.desktop.tools.cliphist;
  hyprCfg = config.samfelag.modules.desktop.wm.hyprland;
  rofiCfg = config.samfelag.modules.desktop.tools.rofi;
in
{
  options.samfelag.modules.desktop.tools.cliphist = {
    enable = mkEnableOption "Clipboard history";
  };

  config = mkIf cfg.enable {

    # - Clipboard manager ------------------------
    hm.services.cliphist = {
      enable = true;
      extraOptions = [
        "-max-dedupe-search"
        "10"
        "-max-items"
        "500"
      ];
    };

    # - Hyprland keybindings ---------------------
    hm.wayland.windowManager.hyprland.settings = lib.mkIf (hyprCfg.enable && rofiCfg.enable) {
        bind = [
          # Clipboard manager
          "${hyprCfg.mod}, v, exec, $HOME/.config/rofi/menus/cliphist/cliphist.sh"
        ];
    };

  };
}
