Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DOCS/interface-changes/env-property.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add env property that can be used to retrieve environment variables
9 changes: 9 additions & 0 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,13 @@ Property list
.. note:: This is only an estimate. (It's computed from two unreliable
quantities: fps and possibly rounded timestamps.)

``env/...``
Read-only property that can be used for retrieving environment variables.
The variable to retrieve should be set as the sub-property. E.g
``${env/HOME}`` will return ``$HOME`` if set.

Note that this property cannot be used directly, a sub-property is required.

``pid``
Process-id of mpv.

Expand Down Expand Up @@ -3643,6 +3650,8 @@ Property list
If tracks of the requested type are selected via ``--lavfi-complex``, the
first one is returned.

Note that this property cannot be used directly, a sub-property is required.

``chapter-list`` (RW)
List of chapters, current entry marked.

Expand Down
12 changes: 12 additions & 0 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,17 @@ static int mp_property_filename(void *ctx, struct m_property *prop,
return r;
}

static int mp_property_env(void *ctx, struct m_property *prop,
int action, void *arg)
{
if (action == M_PROPERTY_KEY_ACTION) {
struct m_property_action_arg *ka = arg;
char *val = getenv(ka->key);
return m_property_strdup_ro(ka->action, ka->arg, val);
}
return M_PROPERTY_NOT_IMPLEMENTED;
}

static int mp_property_stream_open_filename(void *ctx, struct m_property *prop,
int action, void *arg)
{
Expand Down Expand Up @@ -4387,6 +4398,7 @@ static const struct m_property mp_properties_base[] = {
{"video-speed-correction", mp_property_av_speed_correction, .priv = "v"},
{"display-sync-active", mp_property_display_sync_active},
{"filename", mp_property_filename},
{"env", mp_property_env},
{"stream-open-filename", mp_property_stream_open_filename},
{"file-size", mp_property_file_size},
{"path", mp_property_path},
Expand Down
Loading