{
  config,
  lib,
  pkgs,
  ...
}: {
  imports = [../../../stylix];

  options.dotfiles.inputs.home-manager.programs.mpv.enable =
    lib.dotfiles.mkEnableOption;

  config = lib.mkIf config.dotfiles.inputs.home-manager.programs.mpv.enable {
    dotfiles.inputs.stylix.enable = true;

    home.activation =
      lib.dotfiles.home.activation.systemRequirement
      "dotfiles.inputs.home-manager.programs.mpv"
      "programs.dconf.enable = true;"
      "https://nix-community.github.io/home-manager/options.xhtml#opt-services.easyeffects.enable";

    programs.mpv = {
      enable = true;

      scriptOpts = {
        playlistmanager.key_showplaylist = "F8";
        thumbfast.network = "yes";

        # TODO: Patch upstream support. [1]
        #
        # [1]: https://github.com/danth/stylix/issues/185
        uosc = let
          inherit (config.lib.stylix) colors;
        in
          lib.mkIf config.stylix.enable {
            background = colors.base00;
            background_text = colors.base05;
            curtain = colors.base0D;
            error = colors.base0F;
            foreground = colors.base05;
            foreground_text = colors.base00;
            success = colors.base0A;
            top_bar_controls = "no";
          };
      };

      scripts = with pkgs.mpvScripts; [mpv-playlistmanager thumbfast uosc];
    };
  };
}
