summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2014-12-15 01:31:30 +0200
committerwm4 <wm4@nowhere>2014-12-15 04:39:56 +0100
commit39e04e929483847a3e0722d86d53f69837ed99db (patch)
tree56901ce1b9d1cb35f05d3e059d2aca83319491ff
parent06828f71a134e0b880601665c0daea78e6523633 (diff)
downloadmpv-39e04e929483847a3e0722d86d53f69837ed99db.tar.bz2
mpv-39e04e929483847a3e0722d86d53f69837ed99db.tar.xz
options: deprecate 'lua' based options/dirs for 'script'
- --lua and --lua-opts change to --script and --script-opts - 'lua' default script dirs change to 'scripts' - DOCS updated - 'lua-settings' dir was _not_ modified The old lua-based names/dirs still work, but display a warning. Signed-off-by: wm4 <wm4@nowhere>
-rw-r--r--DOCS/man/lua.rst20
-rw-r--r--DOCS/man/mpv.rst10
-rw-r--r--DOCS/man/options.rst12
-rw-r--r--DOCS/man/osc.rst4
-rw-r--r--TOOLS/lua/README.md6
-rw-r--r--TOOLS/lua/autocrop.lua2
-rw-r--r--TOOLS/lua/autodeint.lua2
-rw-r--r--options/options.c6
-rw-r--r--options/options.h4
-rw-r--r--player/lua.c14
-rw-r--r--player/lua/defaults.lua2
-rw-r--r--player/lua/options.lua6
-rw-r--r--player/scripting.c25
13 files changed, 66 insertions, 47 deletions
diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst
index 06450b112b..6d8695ab40 100644
--- a/DOCS/man/lua.rst
+++ b/DOCS/man/lua.rst
@@ -1,10 +1,10 @@
LUA SCRIPTING
=============
-mpv can load Lua scripts. Scripts passed to the ``--lua`` option, or found in
-the ``lua`` subdirectory of the mpv configuration directory (usually
-``~/.config/mpv/lua/``) will be loaded on program start. mpv also appends the
-``lua`` subdirectory to the end of Lua's path so you can import scripts from
+mpv can load Lua scripts. Scripts passed to the ``--script`` option, or found in
+the ``scripts`` subdirectory of the mpv configuration directory (usually
+``~/.config/mpv/scripts/``) will be loaded on program start. mpv also appends the
+``scripts`` subdirectory to the end of Lua's path so you can import scripts from
there too. Since it's added to the end, don't name scripts you want to import
the same as Lua libraries because they will be overshadowed by them.
@@ -35,9 +35,9 @@ allow users implement features which are not going to be added to the mpv core.
Mode of operation
-----------------
-Your script will be loaded by the player at program start from the ``lua``
-configuration subdirectory, from a path specified with the ``--lua`` option, or
-in some cases, internally (like ``--osc``). Each script runs in its own
+Your script will be loaded by the player at program start from the ``scripts``
+configuration subdirectory, from a path specified with the ``--script`` option,
+or in some cases, internally (like ``--osc``). Each script runs in its own
thread. Your script is first run "as is", and once that is done, the event loop
is entered. This event loop will dispatch events received by mpv and call your
own event handlers which you have registered with ``mp.register_event``, or
@@ -361,7 +361,7 @@ The ``mp`` module is preloaded, although it can be loaded manually with
``mp.get_opt(key)``
- Return a setting from the ``--lua-opts`` option. It's up to the user and
+ Return a setting from the ``--script-opts`` option. It's up to the user and
the script how this mechanism is used. Currently, all scripts can access
this equally, so you should be careful about collisions.
@@ -513,12 +513,12 @@ Example config::
optionC=no
-Command-line options are read from the ``--lua-opts`` parameter. To avoid
+Command-line options are read from the ``--script-opts`` parameter. To avoid
collisions, all keys have to be prefixed with ``identifier-``.
Example command-line::
- --lua-opts=myscript-optionA=TEST:myscript-optionB=0:myscript-optionC=yes
+ --script-opts=myscript-optionA=TEST:myscript-optionB=0:myscript-optionC=yes
mp.utils options
diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst
index bbff3cc30b..0c8a0c0214 100644
--- a/DOCS/man/mpv.rst
+++ b/DOCS/man/mpv.rst
@@ -712,9 +712,9 @@ FILES
``~/.config/mpv/input.conf``
key bindings (see `INPUT.CONF`_ section)
-``~/.config/mpv/lua/``
- 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
+``~/.config/mpv/scripts/``
+ All files in this directory are loaded as if they were passed to the
+ ``--script`` option. They are loaded in alphabetical order, and sub-directories
and files with no ``.lua`` extension are ignored. The ``--load-scripts=no``
option disables loading these files.
@@ -738,8 +738,8 @@ locations are different:
``%APPDATA%/mpv/input.conf``
key bindings (see `INPUT.CONF`_ section)
-``%APPDATA%/mpv/lua/``
- equivalent of ``~/.config/mpv/lua/`` on Unix.
+``%APPDATA%/mpv/scripts/``
+ equivalent of ``~/.config/mpv/scripts/`` on Unix.
The environment variable ``$MPV_HOME`` completely overrides these, like on
UNIX.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 9b1ce379ab..7ae04a3b26 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -345,18 +345,18 @@ Program Behavior
Specify configuration file to be parsed after the default ones.
``--load-scripts=<yes|no>``
- If set to ``no``, don't auto-load scripts from the ``lua`` configuration
- subdirectory (usually ``~/.config/mpv/lua/``).
+ If set to ``no``, don't auto-load scripts from the ``scripts``
+ configuration subdirectory (usually ``~/.config/mpv/scripts/``).
(Default: ``yes``)
-``--lua=<filename>``
+``--script=<filename>``
Load a Lua script. You can load multiple scripts by separating them with
commas (``,``).
-``--lua-opts=key1=value1,key2=value2,...``
- Set options for scripts. A Lua script can query an option by key. If an
+``--script-opts=key1=value1,key2=value2,...``
+ Set options for scripts. A script can query an option by key. If an
option is used and what semantics the option value has depends entirely on
- the loaded Lua scripts. Values not claimed by any scripts are ignored.
+ the loaded scripts. Values not claimed by any scripts are ignored.
``--merge-files``
Pretend that all files passed to mpv are concatenated into a single, big
diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst
index 9e2ead0126..d197715f29 100644
--- a/DOCS/man/osc.rst
+++ b/DOCS/man/osc.rst
@@ -138,7 +138,7 @@ Configuration
The OSC offers limited configuration through a config file
``lua-settings/osc.conf`` placed in mpv's user dir and through the
-``--lua-opts`` command-line option. Options provided through the command-line
+``--script-opts`` command-line option. Options provided through the command-line
will override those from the config file.
Config Syntax
@@ -161,7 +161,7 @@ To avoid collisions with other scripts, all options need to be prefixed with
Example::
- --lua-opts=osc-optionA=value1,osc-optionB=value2
+ --script-opts=osc-optionA=value1,osc-optionB=value2
Configurable Options
diff --git a/TOOLS/lua/README.md b/TOOLS/lua/README.md
index 5cd6a54c59..f7cdf2a590 100644
--- a/TOOLS/lua/README.md
+++ b/TOOLS/lua/README.md
@@ -4,9 +4,9 @@ mpv lua scripts
The lua scripts in this folder can be loaded on a one-time basis by
adding the option
- --lua=/path/to/script.lua
+ --script=/path/to/script.lua
to mpv's command line.
-Where appropriate, they may also be placed in ~/.config/mpv/lua from where
-they will be automatically loaded when mpv starts.
+Where appropriate, they may also be placed in ~/.config/mpv/scripts/ from
+where they will be automatically loaded when mpv starts.
diff --git a/TOOLS/lua/autocrop.lua b/TOOLS/lua/autocrop.lua
index cbc4c252ff..35ca618c10 100644
--- a/TOOLS/lua/autocrop.lua
+++ b/TOOLS/lua/autocrop.lua
@@ -21,7 +21,7 @@
-- The default delay between insertion of the cropdetect and
-- crop filters may be overridden by adding
--
--- --lua-opts=autocrop.detect_seconds=<number of seconds>
+-- --script-opts=autocrop.detect_seconds=<number of seconds>
--
-- to mpv's arguments. This may be desirable to allow cropdetect more
-- time to collect data.
diff --git a/TOOLS/lua/autodeint.lua b/TOOLS/lua/autodeint.lua
index d834f96a91..395ac6b3c2 100644
--- a/TOOLS/lua/autodeint.lua
+++ b/TOOLS/lua/autodeint.lua
@@ -19,7 +19,7 @@
--
-- The default detection time may be overridden by adding
--
--- --lua-opts=autodeint.detect_seconds=<number of seconds>
+-- --script-opts=autodeint.detect_seconds=<number of seconds>
--
-- to mpv's arguments. This may be desirable to allow idet more
-- time to collect data.
diff --git a/options/options.c b/options/options.c
index f1bdfde4f8..e3afe5ab14 100644
--- a/options/options.c
+++ b/options/options.c
@@ -127,8 +127,8 @@ const m_option_t mp_opts[] = {
OPT_STRINGLIST("reset-on-next-file", reset_options, M_OPT_GLOBAL),
#if HAVE_LUA
- OPT_STRINGLIST("lua", lua_files, CONF_GLOBAL | M_OPT_FILE),
- OPT_KEYVALUELIST("lua-opts", lua_opts, M_OPT_GLOBAL),
+ OPT_STRINGLIST("script", script_files, CONF_GLOBAL | M_OPT_FILE),
+ OPT_KEYVALUELIST("script-opts", script_opts, M_OPT_GLOBAL),
OPT_FLAG("osc", lua_load_osc, CONF_GLOBAL),
OPT_FLAG("ytdl", lua_load_ytdl, CONF_GLOBAL),
OPT_STRING("ytdl-format", lua_ytdl_format, CONF_GLOBAL),
@@ -594,6 +594,8 @@ const m_option_t mp_opts[] = {
OPT_REMOVED("lavdopts", "use --vd-lavc-..."),
OPT_REMOVED("lavfdopts", "use --demuxer-lavf-..."),
OPT_REPLACED("lircconf", "input-lirc-conf"),
+ OPT_REPLACED("lua", "script"),
+ OPT_REPLACED("lua-opts", "script-opts"),
OPT_REMOVED("mixer-channel", "use AO suboptions (alsa, oss)"),
OPT_REMOVED("mixer", "use AO suboptions (alsa, oss)"),
OPT_REPLACED("mouse-movements", "input-cursor"),
diff --git a/options/options.h b/options/options.h
index a2edf1bb79..21f7c100e6 100644
--- a/options/options.h
+++ b/options/options.h
@@ -59,8 +59,8 @@ typedef struct MPOpts {
int msg_time;
char **reset_options;
- char **lua_files;
- char **lua_opts;
+ char **script_files;
+ char **script_opts;
int lua_load_osc;
int lua_load_ytdl;
char *lua_ytdl_format;
diff --git a/player/lua.c b/player/lua.c
index 7f7fb69bce..992c237867 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -279,10 +279,16 @@ static void set_path(lua_State *L)
const char *path = lua_tostring(L, -1);
char *newpath = talloc_strdup(tmp, path ? path : "");
- char **luadir = mp_find_all_config_files(tmp, get_mpctx(L)->global, "lua");
- for (int i = 0; luadir && luadir[i]; i++) {
- newpath = talloc_asprintf_append(newpath, ";%s",
- mp_path_join(tmp, bstr0(luadir[i]), bstr0("?.lua")));
+ char *dirs[] = {"scripts", "lua", NULL};
+ for (int s = 0; dirs[s]; s++) {
+ char **luadir = mp_find_all_config_files(tmp, get_mpctx(L)->global,
+ dirs[s]);
+ for (int i = 0; luadir && luadir[i]; i++) {
+ // No need to display a warning for lua files in the deprecated
+ // 'lua' dirs since scripting.c already warned on them
+ newpath = talloc_asprintf_append(newpath, ";%s",
+ mp_path_join(tmp, bstr0(luadir[i]), bstr0("?.lua")));
+ }
}
lua_pushstring(L, newpath); // package path newpath
diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua
index bb4eb648ce..4cdeef497f 100644
--- a/player/lua/defaults.lua
+++ b/player/lua/defaults.lua
@@ -14,7 +14,7 @@ function mp.get_script_name()
end
function mp.get_opt(key, def)
- local opts = mp.get_property_native("options/lua-opts")
+ local opts = mp.get_property_native("options/script-opts")
local val = opts[key]
if val == nil then
val = def
diff --git a/player/lua/options.lua b/player/lua/options.lua
index 6e53c2c48a..087e31b6ef 100644
--- a/player/lua/options.lua
+++ b/player/lua/options.lua
@@ -79,18 +79,18 @@ function read_options(options, identifier)
end
--parse command-line options
- for key, val in pairs(mp.get_property_native("options/lua-opts")) do
+ for key, val in pairs(mp.get_property_native("options/script-opts")) do
local prefix = identifier.."-"
if not (string.find(key, prefix, 1, true) == nil) then
key = string.sub(key, string.len(prefix)+1)
-- match found values with defaults
if options[key] == nil then
- msg.warn("lua-opts: unknown key " .. key .. ", ignoring")
+ msg.warn("script-opts: unknown key " .. key .. ", ignoring")
else
local convval = typeconv(options[key], val)
if convval == nil then
- msg.error("lua-opts: error converting value '" .. val ..
+ msg.error("script-opts: error converting value '" .. val ..
"' for key '" .. key .. "'")
else
options[key] = convval
diff --git a/player/scripting.c b/player/scripting.c
index f2ddcec2aa..2ad45075b0 100644
--- a/player/scripting.c
+++ b/player/scripting.c
@@ -179,7 +179,7 @@ void mp_load_scripts(struct MPContext *mpctx)
mp_load_script(mpctx, "@osc.lua");
if (mpctx->opts->lua_load_ytdl)
mp_load_script(mpctx, "@ytdl_hook.lua");
- char **files = mpctx->opts->lua_files;
+ char **files = mpctx->opts->script_files;
for (int n = 0; files && files[n]; n++) {
if (files[n][0])
mp_load_script(mpctx, files[n]);
@@ -187,13 +187,24 @@ void mp_load_scripts(struct MPContext *mpctx)
if (!mpctx->opts->auto_load_scripts)
return;
- // Load all lua scripts
+ // Load all scripts
void *tmp = talloc_new(NULL);
- char **luadir = mp_find_all_config_files(tmp, mpctx->global, "lua");
- for (int i = 0; luadir && luadir[i]; i++) {
- files = list_script_files(tmp, luadir[i]);
- for (int n = 0; files && files[n]; n++)
- mp_load_script(mpctx, files[n]);
+ const char *dirs[] = {"scripts", "lua", NULL}; // 'lua' is deprecated
+ int warning_displayed = 0;
+ for (int s = 0; dirs[s]; s++) {
+ char **scriptsdir = mp_find_all_config_files(tmp, mpctx->global, dirs[s]);
+ for (int i = 0; scriptsdir && scriptsdir[i]; i++) {
+ files = list_script_files(tmp, scriptsdir[i]);
+ for (int n = 0; files && files[n]; n++) {
+ if (s && !warning_displayed) {
+ warning_displayed = 1;
+ MP_WARN(mpctx,
+ "warning: '%s' - '%s' dirs are deprecated. Please move scripts to '%s'.",
+ files[n], dirs[s], dirs[0]);
+ }
+ mp_load_script(mpctx, files[n]);
+ }
+ }
}
talloc_free(tmp);
}