{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.passthrough.catppuccin;
  palette = import ./palette.nix;
in mkIf cfg.enable {
  # cursor theme
  home.pointerCursor = { inherit (cfg.cursor) package name; };
  gtk.cursorTheme = { inherit (cfg.cursor) package name; };

  # gtk theme
  gtk.theme = { inherit (cfg.gtk) package name; };

  # sway colour palette override
  wayland.windowManager.sway.config = {
    colors = with palette.sway.${cfg.sway}; {
      focused =         { border = lavender; background = base; text = text;  indicator = rosewater; childBorder = lavender; };
      focusedInactive = { border = overlay0; background = base; text = text;  indicator = rosewater; childBorder = overlay0; };
      unfocused =       { border = overlay0; background = base; text = text;  indicator = rosewater; childBorder = overlay0; };
      urgent =          { border = peach;    background = base; text = peach; indicator = overlay0;  childBorder = peach; };
      placeholder =     { border = overlay0; background = base; text = text;  indicator = overlay0;  childBorder = overlay0; };
      background =                 base;
    };

    bars = mkForce [ {
      colors = let
        p = palette.sway.${cfg.sway};
      in {
        background =                   p.base;
        statusline =                   p.text;
        focusedStatusline =            p.text;
        focusedSeparator =             p.base;
        focusedWorkspace =  { border = p.base; background = p.base; text = p.green; };
        activeWorkspace =   { border = p.base; background = p.base; text = p.blue; };
        inactiveWorkspace = { border = p.base; background = p.base; text = p.surface1; };
        urgentWorkspace =   { border = p.base; background = p.base; text = p.surface1; };
        bindingMode =       { border = p.base; background = p.base; text = p.surface1; };
      };

      mode = "dock";
      position = "bottom";
      workspaceButtons = true;
      workspaceNumbers = true;
      statusCommand = "${pkgs.i3status}/bin/i3status";
      fonts = {
        names = [ "monospace" ];
        size = 8.0;
      };
      trayOutput = "primary";
    } ];

    output."*".bg = mkForce "${palette.sway.${cfg.sway}.base} solid_color";

    gaps.inner = 12;
    gaps.outer = 5;
    # dodge the status bar
    gaps.bottom = 0;
  };

  programs.i3status.general = with palette.sway.${cfg.sway}; {
    color_good = lavender;
    color_degraded = yellow;
    color_bad = red;
  };

  # foot colour palette override
  programs.foot.settings.colors = {
    inherit (palette.foot.${cfg.sway}) foreground background
    regular0 regular1 regular2 regular3 regular4 regular5 regular6 regular7
    bright0 bright1 bright2 bright3 bright4 bright5 bright6 bright7;
  };
}