{ config, lib, pkgs, ... }: let #mkAnime4kShader = shader: "${pkgs.anime4k}/usr/share/shaders/${shader}"; mkDefaultShader = shader: "${pkgs.mpv-shader-pack}/usr/share/shaders/${shader}"; makeMpvProfile = { shader ? null, gpuContext ? "waylandvk", additional ? {} }: { glsl-shaders = lib.mkIf (shader != null) shader; scale = "ewa_lanczossharp"; cscale = "ewa_lanczossharp"; gpu-context = gpuContext; gpu-api = "vulkan"; hwdec = "vaapi"; vo = "gpu"; video-sync = "display-resample"; interpolation = ""; tscale = "oversample"; } // additional // (if config.ptw.programs.mpv != "" then { # Make mpv pop up on the primary screen screen-name = config.ptw.programs.mpv.primaryScreen; fs-screen-name = config.ptw.programs.mpv.primaryScreen;} else {}); cfg = config.ptw.programs.mpv; in { options.ptw.programs.mpv = { enable = lib.mkEnableOption "Enable and configure mpv using HomeManager"; primaryScreen = lib.mkOption { type = lib.types.str; default = ""; description = "The name of the screen to use for fullscreen"; }; }; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ mpv ]; home-manager.users."${config.ptw.system.singleUser}" = { programs.mpv = { enable = true; config = { script-opts = "try_ytdl_first=no"; }; defaultProfiles = [ "anime" ]; profiles = { anime = (makeMpvProfile { #shader = mkAnime4kShader "Anime4K_Upscale_Denoise_CNN_x2_VL.glsl"; additional = { fullscreen = ""; }; }); anime-denoise = (makeMpvProfile { #shader = mkAnime4kShader "Anime4K_Upscale_Denoise_CNN_x2_VL.glsl"; }); non-anime = (makeMpvProfile { shader = mkDefaultShader "FSRCNNX_x2_8-0-4-1.glsl"; }); non-anime-strong = (makeMpvProfile { shader = mkDefaultShader "FSRCNNX_x2_16-0-4-1.glsl"; }); }; }; }; }; }