Skip to content

Commit

Permalink
command: add an apply-profile command
Browse files Browse the repository at this point in the history
This will actually update all associated options (which is trivial now
with the recent changes).
  • Loading branch information
wm4 committed Sep 17, 2016
1 parent a3e8ff6 commit cb604d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
2 changes: 2 additions & 0 deletions input/cmd_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ const struct mp_cmd_def mp_cmds[] = {
{"reselect", 1})),
}},

{ MP_CMD_APPLY_PROFILE, "apply-profile", {ARG_STRING } },

{0}
};

Expand Down
2 changes: 2 additions & 0 deletions input/cmd_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
8 changes: 8 additions & 0 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cb604d5

Please sign in to comment.