1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 14:52:43 +00:00

lua: add option to disable auto-loading of lua scripts

This commit is contained in:
wm4 2014-02-28 22:25:48 +01:00
parent 47ede0f5e3
commit 1e2d409fb4
5 changed files with 11 additions and 1 deletions

View File

@ -603,7 +603,8 @@ FILES
``~/.mpv/lua/`` ``~/.mpv/lua/``
All files in this directly are loaded as if they were passed to the All files in this directly are loaded as if they were passed to the
``--lua`` option. They are loaded in alphabetical order, and sub-directories ``--lua`` option. They are loaded in alphabetical order, and sub-directories
and files with no ``.lua`` extension are ignored. and files with no ``.lua`` extension are ignored. The ``--load-scripts=no``
option disables loading these files.
EXAMPLES OF MPV USAGE EXAMPLES OF MPV USAGE

View File

@ -1286,6 +1286,10 @@ OPTIONS
``--list-properties`` ``--list-properties``
Print a list of the available properties. Print a list of the available properties.
``--load-scripts=<yes|no>``
If set to ``no``, don't auto-load scripts from ``~/.mpv/lua/``.
(Default: ``yes``)
``--load-unsafe-playlists`` ``--load-unsafe-playlists``
Normally, something like ``mpv playlist.m3u`` won't load the playlist. This Normally, something like ``mpv playlist.m3u`` won't load the playlist. This
is because the playlist code is unsafe. (This is the same in all other is because the playlist code is unsafe. (This is the same in all other

View File

@ -245,6 +245,7 @@ const m_option_t mp_opts[] = {
OPT_STRINGLIST("lua", lua_files, CONF_GLOBAL), OPT_STRINGLIST("lua", lua_files, CONF_GLOBAL),
OPT_KEYVALUELIST("lua-opts", lua_opts, M_OPT_GLOBAL), OPT_KEYVALUELIST("lua-opts", lua_opts, M_OPT_GLOBAL),
OPT_FLAG("osc", lua_load_osc, CONF_GLOBAL), OPT_FLAG("osc", lua_load_osc, CONF_GLOBAL),
OPT_FLAG("load-scripts", auto_load_scripts, CONF_GLOBAL),
#endif #endif
// ------------------------- stream options -------------------- // ------------------------- stream options --------------------
@ -696,6 +697,7 @@ const struct MPOpts mp_default_opts = {
.osd_scale = 1, .osd_scale = 1,
.osd_scale_by_window = 1, .osd_scale_by_window = 1,
.lua_load_osc = 1, .lua_load_osc = 1,
.auto_load_scripts = 1,
.loop_times = -1, .loop_times = -1,
.ordered_chapters = 1, .ordered_chapters = 1,
.chapter_merge_threshold = 100, .chapter_merge_threshold = 100,

View File

@ -55,6 +55,7 @@ typedef struct MPOpts {
char **lua_files; char **lua_files;
char **lua_opts; char **lua_opts;
int lua_load_osc; int lua_load_osc;
int auto_load_scripts;
struct m_obj_settings *audio_driver_list, *ao_defs; struct m_obj_settings *audio_driver_list, *ao_defs;
int fixed_vo; int fixed_vo;

View File

@ -1060,6 +1060,8 @@ void mp_lua_init(struct MPContext *mpctx)
if (files[n][0]) if (files[n][0])
mp_lua_load_script(mpctx, files[n]); mp_lua_load_script(mpctx, files[n]);
} }
if (!mpctx->opts->auto_load_scripts)
return;
// Load ~/.mpv/lua/* // Load ~/.mpv/lua/*
void *tmp = talloc_new(NULL); void *tmp = talloc_new(NULL);
char *lua_path = mp_find_user_config_file(tmp, mpctx->global, "lua"); char *lua_path = mp_find_user_config_file(tmp, mpctx->global, "lua");