office: simple-scan: install
[julm/julm-nix.git] / home-manager / profiles / mpv.nix
index 68a1e50f7a98e2d57d501599f4155ee4a24d1ab2..cd68c8988bfb1b2393268c2679aef84d3cc1f97c 100644 (file)
@@ -1,51 +1,63 @@
-{ pkgs, ... }:
+{ pkgs, lib, ... }:
 {
-  home.packages = [
-    pkgs.mpv
-  ];
-  xdg.configFile."mpv/input.conf".text = ''
-    # Volume normalization
-    # See https://github.com/mpv-player/mpv/issues/3979
-    Alt+a cycle-values af "loudnorm=I=-25:TP=-1.5:LRA=1:linear=false" "dynaudnorm=framelen=100:gausssize=10:coupling=1:peak=0.58" "speechnorm" ""
-    Alt+f cycle video-unscaled
-
-    # Show all chapters (like a right-clic on |<< or >>|)
-    c show_text ''${chapter-list}
-    = show-text ''${playlist}
-    ! show-text ''${track-list}
-
-    # q is easier to type than Q
-    q quit-watch-later
-    ESC quit-watch-later
-    Q quit
-    ENTER playlist-next force
-  '';
-  xdg.configFile."mpv/mpv.conf".text = ''
-    hwdec=auto-safe
-    profile=gpu-hq
-    vo=gpu
-
-    ytdl-format=18/mp4-480p/hls-480p/http-360p/mp4
-
-    # Don't wait ages for the window to finally show up.
-    force-window=immediate
-
-    stop-screensaver=yes
-
-    slang=eng,en,enUS,en-US,fr,fr-FR
-    alang=eng,en,enUS,en-US,fr,fr-FR
-
-    # Higher quality screenshots. Low compression rate to speed up saving.
-    screenshot-directory=~/Images/mpv
-    screenshot-format=avif
-    screenshot-avif-encoder=libsvtav1
-    screenshot-avif-pixfmt=yuv420p
-    # TODO: change crf= wrt. resolution
-    screenshot-avif-opts=crf=24,aq-mode=complexity
-    screenshot-high-bit-depth=yes
-    screenshot-tag-colorspace=yes
-
-    [extension.gif]
-    interpolation=no
-  '';
+  programs.mpv = {
+    enable = true;
+    bindings = {
+      # Volume normalization
+      # See https://github.com/mpv-player/mpv/issues/3979
+      "Alt+a" = ''cycle-values af "loudnorm=I=-25:TP=-1.5:LRA=1:linear=false" "dynaudnorm=framelen=100:gausssize=10:coupling=1:peak=0.58" "speechnorm" ""'';
+      "Alt+f" = "cycle video-unscaled";
+
+      # Show all chapters (like a right-clic on |<< or >>|)
+      "c" = "show_text \${chapter-list}";
+      "=" = "show-text \${playlist}";
+      "!" = "show-text \${track-list}";
+
+      # q is easier to type than Q
+      "q" = "quit-watch-later";
+      "ESC" = "quit-watch-later";
+      "Q" = "quit";
+      "ENTER" = "playlist-next force";
+
+      "Alt+BS" = "playlist-remove current";
+    };
+    config = {
+      af = "loudnorm=I=-25:TP=-1.5:LRA=1:linear=false";
+
+      hwdec = "auto-safe";
+      profile = "gpu-hq";
+      vo = "gpu";
+
+      ytdl-format = "18/mp4-480p/hls-480p/http-360p/mp4";
+
+      # Don't wait ages for the window to finally show up.
+      force-window = "immediate";
+
+      stop-screensaver = "yes";
+
+      slang = "eng,en,enUS,en-US,fr,fr-FR";
+      alang = "eng,en,enUS,en-US,fr,fr-FR";
+      sub-scale = "0.6";
+
+      # For arbtt
+      #title = "MPV: \${?pause==no:playing}\${?pause==yes:paused}: \${path}";
+      title = lib.mkDefault "MPV: \${?pause==no:playing}\${?pause==yes:paused}: ";
+
+      # Higher quality screenshots. Low compression rate to speed up saving.
+      screenshot-directory = "~/Images/mpv";
+      screenshot-template = "%{filename:unknown}.%wH-%wM-%wS-%wT";
+      screenshot-format = "avif";
+      screenshot-avif-encoder = "libsvtav1";
+      screenshot-avif-pixfmt = "yuv420p";
+      # TODO: change crf wrt. resolution
+      screenshot-avif-opts = "crf=24,aq-mode=complexity";
+      screenshot-high-bit-depth = "yes";
+      screenshot-tag-colorspace = "yes";
+    };
+    profiles = {
+      "extension.gif" = {
+        interpolation = "no";
+      };
+    };
+  };
 }