mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
command: add load-config-file
Unlike set include mpv.conf, this works after playback has started. It can be used to auto reload the configuration, e.g. in vim: autocmd BufWritePost ~/.config/mpv/mpv.conf silent !echo load-config-file %:p | socat - /tmp/mpvsocket Partially fixes #6362.
This commit is contained in:
parent
27cb193f0e
commit
e2284fba18
@ -42,6 +42,7 @@ Interface changes
|
|||||||
- add `forced` choice to `subs-with-matching-audio`
|
- add `forced` choice to `subs-with-matching-audio`
|
||||||
- remove `--term-remaining-playtime` option
|
- remove `--term-remaining-playtime` option
|
||||||
- change fallback deinterlace to bwdif
|
- change fallback deinterlace to bwdif
|
||||||
|
- add the command `load-config-file`
|
||||||
--- mpv 0.37.0 ---
|
--- mpv 0.37.0 ---
|
||||||
- `--save-position-on-quit` and its associated commands now store state files
|
- `--save-position-on-quit` and its associated commands now store state files
|
||||||
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
|
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
|
||||||
|
@ -1336,6 +1336,11 @@ Input Commands that are Possibly Subject to Change
|
|||||||
relevant mode. Prints a warning if nothing could be done. See
|
relevant mode. Prints a warning if nothing could be done. See
|
||||||
`Runtime profiles`_ for details.
|
`Runtime profiles`_ for details.
|
||||||
|
|
||||||
|
``load-config-file <filename>``
|
||||||
|
Load a configuration file, similar to the ``--include`` option. If the file
|
||||||
|
was already included, its previous options are not reset before it is
|
||||||
|
reparsed.
|
||||||
|
|
||||||
``load-script <filename>``
|
``load-script <filename>``
|
||||||
Load a script, similar to the ``--script`` option. Whether this waits for
|
Load a script, similar to the ``--script`` option. Whether this waits for
|
||||||
the script to finish initialization or not changed multiple times, and the
|
the script to finish initialization or not changed multiple times, and the
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "options/m_option.h"
|
#include "options/m_option.h"
|
||||||
#include "options/m_property.h"
|
#include "options/m_property.h"
|
||||||
#include "options/m_config_frontend.h"
|
#include "options/m_config_frontend.h"
|
||||||
|
#include "options/parse_configfile.h"
|
||||||
#include "osdep/getpid.h"
|
#include "osdep/getpid.h"
|
||||||
#include "video/out/gpu/context.h"
|
#include "video/out/gpu/context.h"
|
||||||
#include "video/out/vo.h"
|
#include "video/out/vo.h"
|
||||||
@ -6270,6 +6271,23 @@ static void cmd_apply_profile(void *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cmd_load_config_file(void *p)
|
||||||
|
{
|
||||||
|
struct mp_cmd_ctx *cmd = p;
|
||||||
|
struct MPContext *mpctx = cmd->mpctx;
|
||||||
|
|
||||||
|
char *config_file = cmd->args[0].v.s;
|
||||||
|
int r = m_config_parse_config_file(mpctx->mconfig, mpctx->global,
|
||||||
|
config_file, NULL, 0);
|
||||||
|
|
||||||
|
if (r < 1) {
|
||||||
|
cmd->success = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp_notify_property(mpctx, "profile-list");
|
||||||
|
}
|
||||||
|
|
||||||
static void cmd_load_script(void *p)
|
static void cmd_load_script(void *p)
|
||||||
{
|
{
|
||||||
struct mp_cmd_ctx *cmd = p;
|
struct mp_cmd_ctx *cmd = p;
|
||||||
@ -6807,6 +6825,8 @@ const struct mp_cmd_def mp_cmds[] = {
|
|||||||
.flags = MP_CMD_OPT_ARG}, }
|
.flags = MP_CMD_OPT_ARG}, }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ "load-config-file", cmd_load_config_file, {{"filename", OPT_STRING(v.s)}} },
|
||||||
|
|
||||||
{ "load-script", cmd_load_script, {{"filename", OPT_STRING(v.s)}} },
|
{ "load-script", cmd_load_script, {{"filename", OPT_STRING(v.s)}} },
|
||||||
|
|
||||||
{ "dump-cache", cmd_dump_cache, { {"start", OPT_TIME(v.d),
|
{ "dump-cache", cmd_dump_cache, { {"start", OPT_TIME(v.d),
|
||||||
|
@ -164,8 +164,8 @@ local function compile_cond(name, s)
|
|||||||
return chunk
|
return chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
local function load_profiles()
|
local function load_profiles(profiles_property)
|
||||||
for i, v in ipairs(mp.get_property_native("profile-list")) do
|
for _, v in ipairs(profiles_property) do
|
||||||
local cond = v["profile-cond"]
|
local cond = v["profile-cond"]
|
||||||
if cond and #cond > 0 then
|
if cond and #cond > 0 then
|
||||||
local profile = {
|
local profile = {
|
||||||
@ -182,17 +182,25 @@ local function load_profiles()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
load_profiles()
|
mp.observe_property("profile-list", "native", function (_, profiles_property)
|
||||||
|
profiles = {}
|
||||||
|
watched_properties = {}
|
||||||
|
cached_properties = {}
|
||||||
|
properties_to_profiles = {}
|
||||||
|
mp.unobserve_property(on_property_change)
|
||||||
|
|
||||||
if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then
|
load_profiles(profiles_property)
|
||||||
-- make it exit immediately
|
|
||||||
_G.mp_event_loop = function() end
|
if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then
|
||||||
return
|
-- make it exit immediately
|
||||||
end
|
_G.mp_event_loop = function() end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
on_idle() -- re-evaluate all profiles immediately
|
||||||
|
end)
|
||||||
|
|
||||||
mp.register_idle(on_idle)
|
mp.register_idle(on_idle)
|
||||||
for _, name in ipairs({"on_load", "on_preloaded", "on_before_start_file"}) do
|
for _, name in ipairs({"on_load", "on_preloaded", "on_before_start_file"}) do
|
||||||
mp.add_hook(name, 50, on_hook)
|
mp.add_hook(name, 50, on_hook)
|
||||||
end
|
end
|
||||||
|
|
||||||
on_idle() -- re-evaluate all profiles immediately
|
|
||||||
|
Loading…
Reference in New Issue
Block a user