From b8d81ef15ed8ec4c72ffc610279d39aa0c4ccbf0 Mon Sep 17 00:00:00 2001 From: Lichthagel Date: Mon, 29 Apr 2024 15:49:58 +0200 Subject: [PATCH] mpv: add extraInput option --- modules/programs/mpv.nix | 21 +++++++++++++++++-- .../mpv-example-settings-expected-bindings | 3 ++- .../programs/mpv/mpv-example-settings.nix | 4 ++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/programs/mpv.nix b/modules/programs/mpv.nix index eb9c9c4a7..26cad1112 100644 --- a/modules/programs/mpv.nix +++ b/modules/programs/mpv.nix @@ -176,6 +176,20 @@ in { } ''; }; + + extraInput = mkOption { + description = '' + Additional lines that are appended to {file}`$XDG_CONFIG_HOME/mpv/input.conf`. + See {manpage}`mpv(1)` for the full list of options. + ''; + type = with types; lines; + default = ""; + example = '' + esc quit #! Quit + # script-binding uosc/video #! Video tracks + # additional comments + ''; + }; }; }; @@ -199,8 +213,11 @@ in { ${optionalString (cfg.profiles != { }) (renderProfiles cfg.profiles)} ''; }) - (mkIf (cfg.bindings != { }) { - xdg.configFile."mpv/input.conf".text = renderBindings cfg.bindings; + (mkIf (cfg.bindings != { } || cfg.extraInput != "") { + xdg.configFile."mpv/input.conf".text = mkMerge [ + (mkIf (cfg.bindings != { }) (renderBindings cfg.bindings)) + (mkIf (cfg.extraInput != "") cfg.extraInput) + ]; }) { xdg.configFile = mapAttrs' (name: value: diff --git a/tests/modules/programs/mpv/mpv-example-settings-expected-bindings b/tests/modules/programs/mpv/mpv-example-settings-expected-bindings index 7a2ee13b0..d4ff9c4d0 100644 --- a/tests/modules/programs/mpv/mpv-example-settings-expected-bindings +++ b/tests/modules/programs/mpv/mpv-example-settings-expected-bindings @@ -1,3 +1,4 @@ Alt+0 set window-scale 0.5 WHEEL_DOWN seek -10 -WHEEL_UP seek 10 \ No newline at end of file +WHEEL_UP seek 10 +# script-binding uosc/video #! Video tracks diff --git a/tests/modules/programs/mpv/mpv-example-settings.nix b/tests/modules/programs/mpv/mpv-example-settings.nix index 9974aff6b..002e071c1 100644 --- a/tests/modules/programs/mpv/mpv-example-settings.nix +++ b/tests/modules/programs/mpv/mpv-example-settings.nix @@ -12,6 +12,10 @@ "Alt+0" = "set window-scale 0.5"; }; + extraInput = '' + # script-binding uosc/video #! Video tracks + ''; + config = { force-window = true; ytdl-format = "bestvideo+bestaudio";