{ lib, pkgs, config, ... }:
let
  color = n:
    config.environment.graphical.colors."${config.environment.graphical.theme.name}"."${builtins.toString
    n}";
in {
  home-manager.users.agatha = {
    programs.rofi = {
      enable = true;
      font = "DaddyTimeMono Nerd Font 10";
      terminal = "${pkgs.kitty}/bin/kitty";

      theme = let
        inherit (config.home-manager.users.agatha.lib.formats.rasi) mkLiteral;
      in {
        "*" = {
          background = mkLiteral (color 0);
          foreground = mkLiteral (color 15);

          active-background = mkLiteral (color 2);
          active-foreground = mkLiteral "@foreground";
          alternate-active-background = mkLiteral "@background";
          alternate-active-foreground = mkLiteral "@foreground";
          alternate-normal-background = mkLiteral "@background";
          alternate-normal-foreground = mkLiteral "@foreground";
          alternate-urgent-background = mkLiteral "@background";
          alternate-urgent-foreground = mkLiteral "@foreground";
          background-color = mkLiteral "@background";
          border-color = mkLiteral "@background";
          border-radius = mkLiteral "0px";
          lightfg = mkLiteral "#333b5c";
          normal-background = mkLiteral "@background";
          normal-foreground = mkLiteral "@foreground";
          selected-active-background = mkLiteral (color 1);
          selected-active-foreground = mkLiteral "@foreground";
          selected-normal-background = mkLiteral (color 2);
          selected-normal-foreground = mkLiteral "@foreground";
          selected-urgent-background = mkLiteral (color 3);
          selected-urgent-foreground = mkLiteral "@foreground";
          separatorcolor = mkLiteral "@foreground";
          urgent-background = mkLiteral (color 1);
          urgent-foreground = mkLiteral "@foreground";

          spacing = 4;
        };

        "#window" = {
          background-color = mkLiteral "var(background)";
          border-color = mkLiteral "var(urgent-background)";

          width = mkLiteral "30em";
          padding = 5;
          border = 3;
        };

        "#message" = {
          border-color = mkLiteral "@border-color";
          padding = mkLiteral "1px";
        };

        "#textbox" = { text-color = mkLiteral "@foreground"; };

        "#textbox-prompt-colon" = {
          text-color = mkLiteral "@normal-foreground";
        };

        "#listview" = {
          border-color = mkLiteral "@border-color";
          padding = mkLiteral "2px 0px 0px";
          scrollbar = true;
          spacing = mkLiteral "2px";
          fixed-height = 0;
          lines = 10;
        };

        "element" = {
          padding = mkLiteral "5px";
          cursor = mkLiteral "pointer";
        };

        "#element-text, element-icon" = {
          background-color = mkLiteral "transparent";
          text-color = mkLiteral "inherit";
        };

        "#element.normal.normal" = {
          background-color = mkLiteral "@normal-background";
          text-color = mkLiteral "@normal-foreground";
        };

        "#element.normal.urgent" = {
          background-color = mkLiteral "@urgent-background";
          text-color = mkLiteral "@urgent-foreground";
        };

        "#element.normal.active" = {
          background-color = mkLiteral "@active-background";
          text-color = mkLiteral "@active-foreground";
        };

        "#element.selected.normal" = {
          background-color = mkLiteral "@selected-normal-background";
          text-color = mkLiteral "@selected-normal-foreground";
        };

        "#element.selected.urgent" = {
          background-color = mkLiteral "@selected-urgent-background";
          text-color = mkLiteral "@selected-urgent-foreground";
        };

        "#element.selected.active" = {
          background-color = mkLiteral "@selected-active-background";
          text-color = mkLiteral "@selected-active-foreground";
        };

        "#element.alternate.normal" = {
          background-color = mkLiteral "@alternate-normal-background";
          text-color = mkLiteral "@alternate-normal-foreground";
        };

        "#element.alternate.urgent" = {
          background-color = mkLiteral "@alternate-urgent-background";
          text-color = mkLiteral "@alternate-urgent-foreground";
        };

        "#element.alternate.active" = {
          background-color = mkLiteral "@alternate-active-background";
          text-color = mkLiteral "@alternate-active-foreground";
        };

        "#sidebar" = { border-color = mkLiteral "@border-color"; };

        "#button" = { text-color = mkLiteral "@normal-foreground"; };

        "#button.selected" = {
          background-color = mkLiteral "@selected-normal-background";
          text-color = mkLiteral "@selected-normal-foreground";
        };

        "#inputbar" = {
          text-color = mkLiteral "@normal-foreground";
          padding = mkLiteral "1px";
          spacing = mkLiteral "0px";
          children = mkLiteral
            "[ prompt,textbox-prompt-colon,entry,num-filtered-rows,textbox-num-sep,num-rows,case-indicator ]";
        };

        "#case-indicator" = { text-color = mkLiteral "@normal-foreground"; };

        "#entry" = { text-color = mkLiteral "@normal-foreground"; };

        "#prompt" = { text-color = mkLiteral "@normal-foreground"; };

        "num-filtered-rows" = {
          expand = false;
          text-color = mkLiteral (color 8);
        };

        "num-rows" = {
          expand = false;
          text-color = mkLiteral (color 8);
        };

        "textbox-num-sep" = {
          expand = false;
          str = "/";
          text-color = mkLiteral (color 8);
        };

        "textbox-prompt-colon" = {
          margin = mkLiteral "0 0.3em 0 0";
          expand = false;
          str = ":";
        };

        "entry" = {
          text-color = mkLiteral "var(normal-foreground)";
          cursor = mkLiteral "text";
          spacing = 0;
          placeholder-color = mkLiteral (color 8);
          placeholder = "Type to filter";
        };
      };
    };
  };
}
