{
  lib,
  config,
  ...
}:
let
  inherit (lib)
    mkEnableOption
    mkIf
    mkMerge
    ;
  inherit (lib.marleyos) disabled;

  cfg = config.marleyos.services.dunst;
  inherit (config.marleyos.theme) colors;

  isRosePine = colors.base == "rose-pine";
in
{
  options.marleyos.services.dunst.enable = mkEnableOption "dunst";

  config = mkIf cfg.enable {
    services.dunst = {
      enable = true;

      # I don't want to use the rose-pine icons; also don't want to deal with
      # the drop-in weirdness.
      # TODO: Convert dunst.rose-pine to attr set to fix this.
      rose-pine = disabled;

      settings = mkMerge [
        ### Rose Pine ###
        (mkIf isRosePine {
          global = {
            width = 400;
            offset = "20x60";
            progress_bar_min_width = 380;
            progress_bar_max_width = 380;
            progress_bar_corner_radius = 2;
            padding = 10;
            horizontal_padding = 10;
            frame_width = 1;
            gap_size = 3;
            corner_radius = 2;
            background = "#26233a";
            foreground = "#e0def4";
          };

          urgency_low = {
            background = "#26273d";
            highlight = "#31748f";
            frame_color = "#31748f";
            default_icon = "dialog-information";
            format = "<b><span foreground='#31748f'>%s</span></b>\\n%b";
          };

          urgency_normal = {
            background = "#362e3c";
            highlight = "#f6c177";
            frame_color = "#f6c177";
            default_icon = "dialog-warning";
            format = "<b><span foreground='#f6c177'>%s</span></b>\\n%b";
          };

          urgency_critical = {
            background = "#35263d";
            highlight = "#eb6f92";
            frame_color = "#eb6f92";
            default_icon = "dialog-error";
            format = "<b><span foreground='#eb6f92'>%s</span></b>\\n%b";
          };
        })

        ### Custom ###
        {
          global = {
            monitor = 0;
            sort = "yes";
            idle_threshold = 120;
            font = (builtins.head config.fonts.fontconfig.defaultFonts.monospace) + " 10";
            markup = "full";
            show_age_threshold = 60;
            word_wrap = "yes";
            ignore_newline = "no";
            stack_duplicates = true;
            hide_duplicate_count = false;
            show_indicators = "yes";
            sticky_history = "yes";
            history_length = 20;
            browser = "/usr/bin/zen-browser --new-tab";
            always_run_script = true;
            title = "Dunst";
            class = "Dunst";
            mouse_left_click = "do_action";
            mouse_middle_click = "close_current";
            mouse_right_click = "close_all";
          };

          signed_on = {
            appname = "Pidgin";
            summary = "*signed on*";
            urgency = "low";
          };

          signed_off = {
            appname = "Pidgin";
            summary = "*signed off*";
            urgency = "low";
          };

          says = {
            appname = "Pidgin";
            summary = "*says*";
            urgency = "critical";
          };
        }
      ];
    };
  };
}
