summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-10-12 16:35:18 +0300
committeravih <avih@users.noreply.github.com>2021-10-19 15:43:39 +0300
commit4703b74e6c04e8e0760ad366ac0ee39576d9ff88 (patch)
treebf475df880aa60776a7abac8c4485954faadb817 /player
parente13fe1299d8aefdc264e74159cce07b8bfcf722c (diff)
downloadmpv-4703b74e6c04e8e0760ad366ac0ee39576d9ff88.tar.bz2
mpv-4703b74e6c04e8e0760ad366ac0ee39576d9ff88.tar.xz
js: custom-init: use ~~/init.js instead of ~~/.init.js (dot)
mpv doesn't have other dot files in its config dir, and it also shouldn't be "invisible". The new name ~~/init.js now replaces ~~/.init.js While mpv usually deprecates things before outright removing them, in this case the old (dot) name is replaced without deprecation: - It's a bad idea to execute hidden scripts, even if at a config dir, and we don't want to do that for the next release cycle too. - We warn if the old (dot) name exists and the new name doesn't, which should be reasonably visible for affected users. - It's likely niche enough to not cause too much pain. If for some reason both names are needed, e.g. when using also an old mpv versions, then the old name could be symlinked to the new one, or simply have one line: `require("~~/init")` to load the new name, while a new mpv version will load (only) the new name without warning.
Diffstat (limited to 'player')
-rw-r--r--player/javascript/defaults.js16
1 files changed, 10 insertions, 6 deletions
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)