{ pkgs
, lib
, config
, ... }: with lib; let
  cfg = config.passthrough.catppuccin;
  palette = (lib.importJSON "${config.catppuccin.sources.palette}/palette.json").${config.catppuccin.flavor}.colors;
in mkIf cfg.enable {
  gtk.theme = { inherit (cfg.gtk) package name; };
  qt.style.name = "kvantum";
  qt.platformTheme.name = "kvantum";
  home.pointerCursor = { inherit (cfg.cursor) package name; };

  # sway colour palette override
  wayland.windowManager.sway.config = {
    colors = {
      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 = {
        background =                   "$base";
        statusline =                   "$text";
        focusedStatusline =            "$text";
        focusedSeparator =             "$base";
        focusedWorkspace =  { border = "$base"; background = "$base"; text = "$green"; };
        activeWorkspace =   { border = "$base"; background = "$base"; text = "$blue"; };
        inactiveWorkspace = { border = "$base"; background = "$base"; text = "$surface1"; };
        urgentWorkspace =   { border = "$base"; background = "$base"; text = "$surface1"; };
        bindingMode =       { border = "$base"; background = "$base"; text = "$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 "${./flake.png} fill";
    gaps.inner = 12;
    gaps.outer = 5;
    # dodge the status bar
    gaps.bottom = 0;
  };

  # i3status colour palette override
  programs.i3status.general = with palette; {
    color_good = lavender.hex;
    color_degraded = yellow.hex;
    color_bad = red.hex;
  };
}
