From f386fd79b2df57d54d5ec0d93d4958f56a527631 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Tue, 12 Oct 2021 08:11:11 +0300 Subject: [PATCH] js: custom init: ignore ~~/.init.js with --no-config The custom init script should be considered a configuration file, and as such it should be ignored when the user wants vanilla mpv - and now it is ignored with --no-config. --- DOCS/man/javascript.rst | 2 ++ player/javascript/defaults.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/DOCS/man/javascript.rst b/DOCS/man/javascript.rst index a8687ff692..75d3033f4e 100644 --- a/DOCS/man/javascript.rst +++ b/DOCS/man/javascript.rst @@ -343,6 +343,8 @@ for all scripts. E.g. if it contains ``mp.module_paths.push("/foo")`` then (do NOT do ``mp.module_paths = ["/foo"];`` because this will remove existing paths - like ``/modules`` for scripts which load from a directory). +The custom-init file is ignored if mpv is invoked with ``--no-config``. + The event loop -------------- diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index 4393925efe..8f5d3089ec 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -773,5 +773,8 @@ g.mp_event_loop = function mp_event_loop() { // let the user extend us, e.g. by adding items to mp.module_paths // (unlike e.g. read_file, file_info doesn't expand meta-paths) -if (mp.utils.file_info(mp.utils.get_user_path("~~/.init.js"))) +if (mp.get_property_bool("config") && // --no-config disables custom init + mp.utils.file_info(mp.utils.get_user_path("~~/.init.js"))) +{ require("~~/.init"); +}