From dcdeece6a29656e24a800f5dafa8f7ea409b9291 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 29 Oct 2021 20:58:40 +0200 Subject: [PATCH] mpv: Reorganise non-home-manager scripts and options --- users/simon/modules/mpv/default.nix | 52 +++++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/users/simon/modules/mpv/default.nix b/users/simon/modules/mpv/default.nix index 05466fb..6633942 100644 --- a/users/simon/modules/mpv/default.nix +++ b/users/simon/modules/mpv/default.nix @@ -234,27 +234,35 @@ in }; }; - # mpv-gallery-view is not compatible with home-manager’s script injection meachanism - xdg.configFile."mpv/scripts/gallery-thumbgen-0.lua".source = "${gallery-view}/scripts/gallery-thumbgen.lua"; - xdg.configFile."mpv/scripts/gallery-thumbgen-1.lua".source = "${gallery-view}/scripts/gallery-thumbgen.lua"; - xdg.configFile."mpv/scripts/gallery-thumbgen-2.lua".source = "${gallery-view}/scripts/gallery-thumbgen.lua"; - xdg.configFile."mpv/scripts/gallery-thumbgen-3.lua".source = "${gallery-view}/scripts/gallery-thumbgen.lua"; - xdg.configFile."mpv/scripts/lib.disable/gallery.lua".source = "${gallery-view}/scripts/lib.disable/gallery.lua"; - xdg.configFile."mpv/scripts/playlist-view.lua".source = "${gallery-view}/scripts/playlist-view.lua"; - xdg.configFile."mpv/script-opts/playlist_view.conf".text = '' - thumbs_dir=${config.xdg.cacheHome}/thumbnails/mpv - ''; + xdg.configFile = { + # scripts that are incompatible with home-manager’s mechanism + "mpv/scripts/lib.disable/gallery.lua".source = "${gallery-view}/scripts/lib.disable/gallery.lua"; + "mpv/scripts/playlist-view.lua".source = "${gallery-view}/scripts/playlist-view.lua"; + + # script options + "mpv/script-opts/playlist_view.conf".text = '' + thumbs_dir=${config.xdg.cacheHome}/thumbnails/mpv + ''; + + # make ytdl-hook use yt-dlp + "mpv/script-opts/ytdl_hook.conf".text = '' + ytdl_path=${pkgs.unstable.yt-dlp}/bin/yt-dlp + ''; + + "mpv/script-opts/stats.conf".text = '' + font=${config.programs.mpv.config.osd-font} + font_mono=${config.programs.mpv.config.osd-font} + font_size=10 + redraw_delay=0.25 + ''; + # mpv-gallery-view’s thumbnail generation mechanism supports multithreading by linking it multiple times + } // lib.listToAttrs + (map + (i: lib.nameValuePair + "mpv/scripts/gallery-thumbgen-${toString i}.lua" + { source = "${gallery-view}/scripts/gallery-thumbgen.lua"; }) + (lib.range 1 16)); + + # dummy file home.file."${config.xdg.cacheHome}/thumbnails/mpv/.create".text = ""; - - # Make ytdl-hook use yt-dlp - xdg.configFile."mpv/script-opts/ytdl_hook.conf".text = '' - ytdl_path=${pkgs.unstable.yt-dlp}/bin/yt-dlp - ''; - - xdg.configFile."mpv/script-opts/stats.conf".text = '' - font=${config.programs.mpv.config.osd-font} - font_mono=${config.programs.mpv.config.osd-font} - font_size=10 - redraw_delay=0.25 - ''; }