{ config, lib, userName, pkgs, sources, ... }: { home-manager.users.${userName} = { programs.mpv = { enable = true; bindings = { # "CTRL+n" = "af toggle \"lavfi=[dynaudnorm=f=100:g=31:s=20.0]\""; }; config = { ytdl = true; subs-with-matching-audio = false; audio-display = false; osd-font = "Fira Sans"; sub-font = "Fira Sans"; # vo = "gpu"; vo = "gpu-next"; hwdec = "auto"; scale = "bilinear"; force-window = "yes"; # af = "lavfi=[dynaudnorm=f=100:g=31:s=20.0]"; script-opts = lib.concatStringsSep "," [ "osc-layout=topbar" "vidscale=no" "deadzonesize=0.9" "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp" "chapterskip-skip=sponsor;intro;endcard;interact" "chapterskip-categories=sponsor>%[SponsorBlock%]: .*Sponsor.*;intro>%[SponsorBlock%]: .*Intro Animation.*;endcard>%[SponsorBlock%]: .*Endcards.*;interact>%[SponsorBlock%]: .*Interaction Reminder.*" "sub_select-config=${pkgs.writeTextDir "sub-select.json" (builtins.toJSON [ { alang = "*"; slang = "forced"; } { alang = ["jpn" "ja"]; slang = "eng?"; blacklist = [ "sign" ]; } { alang = ["jpn" "ja"]; slang = "und"; blacklist = [ "sign" ]; } { alang = ["eng?" "deu?"]; slang = "no"; } { alang = "*"; slang = "eng?"; } { alang = "*"; slang = "und"; } ])}" ]; watch-later-options = lib.concatStringsSep "," [ "start" ]; }; scripts = [ (pkgs.stdenv.mkDerivation (sources.mpv-reload // rec { installPhase = '' install -d $out/share/mpv/scripts install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName} ''; passthru.scriptName = "reload.lua"; })) (pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec { installPhase = '' install -d $out/share/mpv/scripts install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName} ''; passthru.scriptName = "createchapter.lua"; })) (pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec { installPhase = '' install -d $out/share/mpv/scripts install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName} ''; passthru.scriptName = "autosave.lua"; })) (pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec { installPhase = '' install -d $out/share/mpv/scripts install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName} ''; nativeBuildInputs = with pkgs; [ pkg-config glib mpv ffmpeg.dev ]; passthru.scriptName = "mpris.so"; })) (pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec { installPhase = '' install -d $out/share/mpv/scripts install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName} ''; passthru.scriptName = "chapterskip.lua"; })) (pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec { installPhase = '' install -d $out/share/mpv/scripts install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName} ''; passthru.scriptName = "sub-select.lua"; })) (pkgs.stdenv.mkDerivation (sources.mpv-youtube-quality // rec { patches = [ (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/31.patch"; hash = "sha256-2aTTkW48uRe8XC1ZQ8J5T9sUmZ5F3YAoYCMxqEs2AY8="; }) (pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/20.patch"; hash = "sha256-X5BwDsxziYbeiQvrBt8+IS+6oH1i0LvaaYtugL790gg="; }) ]; installPhase = '' install -d $out/share/mpv/scripts install -m 0644 youtube-quality.lua $out/share/mpv/scripts/${passthru.scriptName} ''; passthru.scriptName = "youtube-quality.lua"; })) ]; }; xdg.configFile."mpv/youtube-dl".source = "${pkgs.yt-dlp}/bin/yt-dlp"; }; }