From b04d83a755b11acd0c235b499fbe5580ee510eb5 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sat, 1 Feb 2025 09:36:29 +0100
Subject: [PATCH] Add mpv.

---
 modules/home-manager/default.nix |  2 ++
 modules/home-manager/mpv.nix     | 54 ++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 modules/home-manager/mpv.nix

diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix
index 8795ec4..262cfbc 100644
--- a/modules/home-manager/default.nix
+++ b/modules/home-manager/default.nix
@@ -5,6 +5,7 @@
     ./zsh.nix
     ./tmux.nix
     ./nnn.nix
+    ./mpv.nix
   ];
 
   crony.mangohud.enable = lib.mkDefault true;
@@ -12,4 +13,5 @@
   crony.zsh.enable = lib.mkDefault true;
   crony.tmux.enable = lib.mkDefault true;
   crony.nnn.enable = lib.mkDefault true;
+  crony.mpv.enable = lib.mkDefault true;
 }
diff --git a/modules/home-manager/mpv.nix b/modules/home-manager/mpv.nix
new file mode 100644
index 0000000..b16f808
--- /dev/null
+++ b/modules/home-manager/mpv.nix
@@ -0,0 +1,54 @@
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}: {
+  options = {
+    crony.mpv.enable = lib.mkEnableOption "Enable mpv and customize it to my preference.";
+  };
+
+  config = lib.mkIf config.crony.mpv.enable {
+    programs.mpv = {
+      enable = true;
+      config = {
+        ytdl-format = "ytdl-format=bestvideo[height<=?1080][fps<=?60][vcodec!~='vp0?9'][vcodec!*=av01]+bestaudio/best";
+        fs = true;
+        force-window = "immediate";
+        hr-seek-framedrop = "no";
+        profile = "gpu-hq";
+        hwdec = "nvdec-copy";
+        gpu-api = "vulkan";
+        vo = "gpu-next";
+        screenshot-format = "png";
+        screenshot-high-bit-depth = "yes";
+        screenshot-png-compression = "7";
+        screenshot-directory = "~/pics/mpv/";
+        screenshot-template = "%F - [%P]v%#01n";
+        alang = "'jpn,jp,eng,en'";
+        sub-file-paths = "Subs;subs";
+        sub-auto = "all";
+        slang = "english,eng,en,enUS";
+        reset-on-next-file = "pause";
+        #        no-osd-bar = false;
+        osd-duration = "500";
+        deband = "yes";
+        deband-iterations = "2";
+        deband-threshold = "35";
+        deband-range = "20";
+        deband-grain = "5";
+        dither-depth = "auto";
+        scale = "ewa_lanczossharp";
+        dscale = "mitchell";
+        cscale = "spline36";
+      };
+
+      scripts = with pkgs.mpvScripts; [
+        mpris
+        sponsorblock
+        thumbfast
+        quality-menu
+      ];
+    };
+  };
+}