mirror of https://github.com/mpv-player/mpv
command: add load-input-conf
This can be used to auto reload the input configuration file, e.g. in vim: autocmd BufWritePost ~/.config/mpv/input.conf silent !echo load-input-conf %:p | socat - /tmp/mpvsocket Partially fixes #6362. Additionally this can be used as a replacement for deprecated input sections if they are ever actually removed. For example, if you want to define different bindings for images, you can load-input-conf an input.conf for images, and load the original again when switching to a video. Though currently you would have to redefine builtin bindings that were overwritten with image ones in the default input.conf.
This commit is contained in:
parent
68e3412fee
commit
4ab521f080
|
@ -43,6 +43,7 @@ Interface changes
|
||||||
- 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`
|
- add the command `load-config-file`
|
||||||
|
- add the command `load-input-conf`
|
||||||
--- 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.
|
||||||
|
|
|
@ -1341,6 +1341,11 @@ Input Commands that are Possibly Subject to Change
|
||||||
was already included, its previous options are not reset before it is
|
was already included, its previous options are not reset before it is
|
||||||
reparsed.
|
reparsed.
|
||||||
|
|
||||||
|
``load-input-conf <filename>``
|
||||||
|
Load an input configuration file, similar to the ``--input-conf`` option. If
|
||||||
|
the file was already included, its previous bindings 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
|
||||||
|
|
|
@ -1395,6 +1395,14 @@ void mp_input_load_config(struct input_ctx *ictx)
|
||||||
input_unlock(ictx);
|
input_unlock(ictx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool mp_input_load_config_file(struct input_ctx *ictx, char *file)
|
||||||
|
{
|
||||||
|
input_lock(ictx);
|
||||||
|
bool result = parse_config_file(ictx, file);
|
||||||
|
input_unlock(ictx);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void clear_queue(struct cmd_queue *queue)
|
static void clear_queue(struct cmd_queue *queue)
|
||||||
{
|
{
|
||||||
while (queue->first) {
|
while (queue->first) {
|
||||||
|
|
|
@ -178,8 +178,12 @@ struct input_ctx *mp_input_init(struct mpv_global *global,
|
||||||
void (*wakeup_cb)(void *ctx),
|
void (*wakeup_cb)(void *ctx),
|
||||||
void *wakeup_ctx);
|
void *wakeup_ctx);
|
||||||
|
|
||||||
|
// Load the configured input.conf files.
|
||||||
void mp_input_load_config(struct input_ctx *ictx);
|
void mp_input_load_config(struct input_ctx *ictx);
|
||||||
|
|
||||||
|
// Load a specific input.conf file.
|
||||||
|
bool mp_input_load_config_file(struct input_ctx *ictx, char *file);
|
||||||
|
|
||||||
void mp_input_update_opts(struct input_ctx *ictx);
|
void mp_input_update_opts(struct input_ctx *ictx);
|
||||||
|
|
||||||
void mp_input_uninit(struct input_ctx *ictx);
|
void mp_input_uninit(struct input_ctx *ictx);
|
||||||
|
|
|
@ -6288,6 +6288,15 @@ static void cmd_load_config_file(void *p)
|
||||||
mp_notify_property(mpctx, "profile-list");
|
mp_notify_property(mpctx, "profile-list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cmd_load_input_conf(void *p)
|
||||||
|
{
|
||||||
|
struct mp_cmd_ctx *cmd = p;
|
||||||
|
struct MPContext *mpctx = cmd->mpctx;
|
||||||
|
|
||||||
|
char *config_file = cmd->args[0].v.s;
|
||||||
|
cmd->success = mp_input_load_config_file(mpctx->input, config_file);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -6827,6 +6836,8 @@ const struct mp_cmd_def mp_cmds[] = {
|
||||||
|
|
||||||
{ "load-config-file", cmd_load_config_file, {{"filename", OPT_STRING(v.s)}} },
|
{ "load-config-file", cmd_load_config_file, {{"filename", OPT_STRING(v.s)}} },
|
||||||
|
|
||||||
|
{ "load-input-conf", cmd_load_input_conf, {{"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),
|
||||||
|
|
Loading…
Reference in New Issue