command: add an apply-profile command

This will actually update all associated options (which is trivial now
with the recent changes).
This commit is contained in:
wm4 2016-09-17 21:01:59 +02:00
parent a3e8ff624c
commit cb604d5412
4 changed files with 20 additions and 0 deletions

View File

@ -691,6 +691,14 @@ Input Commands that are Possibly Subject to Change
``af-command "<label>" "<cmd>" "<args>"``
Same as ``vf-command``, but for audio filters.
``apply-profile "<name>"``
Apply the contents of a named profile. This is like using ``profile=name``
in a config file, except you can map it to a key binding to change it at
runtime.
There is no such thing as "unapplying" a profile - applying a profile
merely sets all option values listed within the profile.
Undocumented commands: ``tv-last-channel`` (TV/DVB only),
``ao-reload`` (experimental/internal).

View File

@ -224,6 +224,8 @@ const struct mp_cmd_def mp_cmds[] = {
{"reselect", 1})),
}},
{ MP_CMD_APPLY_PROFILE, "apply-profile", {ARG_STRING } },
{0}
};

View File

@ -114,6 +114,8 @@ enum mp_command_type {
MP_CMD_RESCAN_EXTERNAL_FILES,
MP_CMD_APPLY_PROFILE,
// Internal
MP_CMD_COMMAND_LIST, // list of sub-commands in args[0].v.p
};

View File

@ -5514,6 +5514,14 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
break;
}
case MP_CMD_APPLY_PROFILE: {
char *profile = cmd->args[0].v.s;
int flags = mpctx->initialized ? M_SETOPT_RUNTIME : 0;
if (m_config_set_profile(mpctx->mconfig, profile, flags) < 0)
return -1;
break;
}
default:
MP_VERBOSE(mpctx, "Received unknown cmd %s\n", cmd->name);
return -1;