config/users/pbsds/home/profiles/mpv.nix

57 lines
3.9 KiB
Nix
Raw Normal View History

2024-01-31 02:11:55 +01:00
{ lib, pkgs, ... }:
2024-01-26 01:46:33 +01:00
let
m = pkgs.mpvScripts;
2024-01-26 02:08:22 +01:00
mu = pkgs.unstable.mpvScripts;
2024-01-31 02:11:55 +01:00
anime4k = pkgs.anime4k or pkgs.unstable.anime4k or null;
a4k = lib.mkIf (anime4k != null);
2024-01-26 01:46:33 +01:00
in
2023-03-04 00:09:57 +01:00
{
2023-03-09 07:03:15 +01:00
#home.packages = with pkgs; [ mpv ];
2023-03-04 00:09:57 +01:00
programs.mpv.enable = true;
2023-03-11 16:00:42 +01:00
programs.mpv.bindings."n" = "sub-seek 1";
2023-03-04 00:09:57 +01:00
programs.mpv.bindings."SHIFT+n" = "sub-seek -1";
2024-01-26 01:46:33 +01:00
programs.mpv.bindings."b" = ''cycle-values audio-channels 2 5 7 "auto"'';
2024-01-31 02:11:55 +01:00
# WeChip g20 voice remote
programs.mpv.bindings."homepage" = "cycle fullscreen";
# anime4k - from https://github.com/NixOS/nixpkgs/pull/273830
2024-01-26 01:46:33 +01:00
# TODO: add to home-manager?
programs.mpv.bindings."CTRL+0" = a4k ''no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared"'';
2024-01-31 02:11:55 +01:00
programs.mpv.bindings."CTRL+1" = a4k ''no-osd change-list glsl-shaders set "${anime4k}/Anime4K_Clamp_Highlights.glsl:${anime4k}/Anime4K_Restore_CNN_VL.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode A (HQ)"'';
programs.mpv.bindings."CTRL+2" = a4k ''no-osd change-list glsl-shaders set "${anime4k}/Anime4K_Clamp_Highlights.glsl:${anime4k}/Anime4K_Restore_CNN_Soft_VL.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode B (HQ)"'';
programs.mpv.bindings."CTRL+3" = a4k ''no-osd change-list glsl-shaders set "${anime4k}/Anime4K_Clamp_Highlights.glsl:${anime4k}/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:${anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C (HQ)"'';
programs.mpv.bindings."CTRL+4" = a4k ''no-osd change-list glsl-shaders set "${anime4k}/Anime4K_Clamp_Highlights.glsl:${anime4k}/Anime4K_Restore_CNN_VL.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${anime4k}/Anime4K_Restore_CNN_M.glsl:${anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode A+A (HQ)"'';
programs.mpv.bindings."CTRL+5" = a4k ''no-osd change-list glsl-shaders set "${anime4k}/Anime4K_Clamp_Highlights.glsl:${anime4k}/Anime4K_Restore_CNN_Soft_VL.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_VL.glsl:${anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${anime4k}/Anime4K_Restore_CNN_Soft_M.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode B+B (HQ)"'';
programs.mpv.bindings."CTRL+6" = a4k ''no-osd change-list glsl-shaders set "${anime4k}/Anime4K_Clamp_Highlights.glsl:${anime4k}/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:${anime4k}/Anime4K_AutoDownscalePre_x2.glsl:${anime4k}/Anime4K_AutoDownscalePre_x4.glsl:${anime4k}/Anime4K_Restore_CNN_M.glsl:${anime4k}/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C+A (HQ)"'';
2024-01-26 01:46:33 +01:00
/**/
2023-06-13 01:07:47 +02:00
2024-01-26 01:46:33 +01:00
programs.mpv.scripts = [
#m.thumbnail # TOO SLOW
m.thumbfast
m.mpris
2024-01-26 02:08:22 +01:00
(m.mpv-webm or mu.mpv-webm) # activate with SHIFT+W
2023-06-20 21:37:24 +02:00
# from https://github.com/mpv-player/mpv/issues/9767#issuecomment-1024831645
({ scriptName = "dynamic-subs.lua"; } // (pkgs.writeTextDir "share/mpv/scripts/dynamic-subs.lua" ''
mp.add_hook('on_load', 10, function()
sub_paths = {'Subs'}
sub_paths[#sub_paths+1]='Subs/' .. mp.get_property('filename/no-ext')
mp.set_property_native('sub-file-paths', sub_paths)
end)
''))
2023-06-20 01:39:19 +02:00
];
2023-06-13 01:07:47 +02:00
#programs.mpv.config.osc = "no"; # likely a 'thumbnail' requirement
2023-03-11 16:00:42 +01:00
2023-06-20 21:37:24 +02:00
# dynamic-subs.lua
programs.mpv.config.sub-auto = "all";
2023-03-11 16:00:42 +01:00
#https://nixos.wiki/wiki/Accelerated_Video_Playback
programs.mpv.config.hwdec = "auto-safe";
programs.mpv.config.vo = "gpu";
programs.mpv.config.profile = "gpu-hq";
2024-05-30 20:45:37 +02:00
#programs.mpv.config.gpu-context = "wayland";
2023-03-04 00:09:57 +01:00
}