{
  config,
  osConfig,
  lib,
  pkgs,
  ...
}: let
  cfg = config.marleyos.programs.cava;
  has-mpd = osConfig.services.mpd.enable || config.services.mpd.enable;
in {
  options.marleyos.programs.cava.enable = lib.mkEnableOption "cava";

  config = lib.mkIf (cfg.enable && pkgs.stdenv.isLinux) {
    programs.cava = {
      enable = true;

      settings = {
        input = lib.mkIf has-mpd {
          method = "fifo";
          source = "/tmp/mpd.fifo";
        };
      };
    };

    stylix.targets.cava = {
      enable = true;
      rainbow.enable = true;
    };
  };
}
