summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/javascript.rst4
-rw-r--r--player/javascript/defaults.js16
3 files changed, 15 insertions, 7 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 8cf94ceaa0..6e20fa2329 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -47,6 +47,8 @@ Interface changes
bindings during start-up (default: yes).
- add ``track-list/N/image`` sub-property
- remove `--opengl-restrict` option
+ - js custom-init: use filename ~~/init.js instead of ~~/.init.js (dot)
+
--- mpv 0.33.0 ---
- add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode
when the player enters fullscreen.
diff --git a/DOCS/man/javascript.rst b/DOCS/man/javascript.rst
index 75d3033f4e..e1b93d8204 100644
--- a/DOCS/man/javascript.rst
+++ b/DOCS/man/javascript.rst
@@ -336,7 +336,7 @@ Custom initialization
---------------------
After mpv initializes the JavaScript environment for a script but before it
-loads the script - it tries to run the file ``.init.js`` at the root of the mpv
+loads the script - it tries to run the file ``init.js`` at the root of the mpv
configuration directory. Code at this file can update the environment further
for all scripts. E.g. if it contains ``mp.module_paths.push("/foo")`` then
``require`` at all scripts will search global module id's also at ``/foo``
@@ -345,6 +345,8 @@ paths - like ``<script-dir>/modules`` for scripts which load from a directory).
The custom-init file is ignored if mpv is invoked with ``--no-config``.
+Before mpv 0.34, the file name was ``.init.js`` (with dot) at the same dir.
+
The event loop
--------------
diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js
index 8f5d3089ec..d489bed256 100644
--- a/player/javascript/defaults.js
+++ b/player/javascript/defaults.js
@@ -769,12 +769,16 @@ g.mp_event_loop = function mp_event_loop() {
} while (mp.keep_running);
};
-})(this)
// 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.get_property_bool("config") && // --no-config disables custom init
- mp.utils.file_info(mp.utils.get_user_path("~~/.init.js")))
-{
- require("~~/.init");
+if (mp.get_property_bool("config")) { // --no-config disables custom init
+ // file_info doesn't expand meta-paths (other file functions do)
+ var file_info = mp.utils.file_info, user_path = mp.utils.get_user_path;
+
+ if (file_info(user_path("~~/init.js")))
+ require("~~/init");
+ else if (file_info(user_path("~~/.init.js")))
+ mp.msg.warn("Config file ~~/.init.js is ignored. Use ~~/init.js");
}
+
+})(this)