diff options
author | Guido Cella <guido@guidocella.xyz> | 2023-04-04 21:38:04 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-04-05 18:32:18 +0000 |
commit | 41372c5e1f6675099d4e0647489595c052116d0f (patch) | |
tree | d36c8449b29fc7393642c311a4d4bb81babd7a02 /DOCS/man/mpv.rst | |
parent | b7ffe0d16eec8153d9609382997baaf6a29e5e4f (diff) | |
download | mpv-41372c5e1f6675099d4e0647489595c052116d0f.tar.bz2 mpv-41372c5e1f6675099d4e0647489595c052116d0f.tar.xz |
auto_profiles.lua: apply profiles when conditions are truthy
Instead of erroring when values returned by profile-cond expressions
aren't booleans, apply the relative profiles as long as the return
values are truthy. This allows shortening conditions like
profile-cond=path:match('foo') ~= nil
to
profile-cond=path:match('foo')
Diffstat (limited to 'DOCS/man/mpv.rst')
-rw-r--r-- | DOCS/man/mpv.rst | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index 01aefd1e7a..c1314ef2c2 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -793,9 +793,10 @@ Conditional auto profiles Profiles which have the ``profile-cond`` option set are applied automatically if the associated condition matches (unless auto profiles are disabled). The -option takes a string, which is interpreted as Lua condition. If evaluating the -expression returns true, the profile is applied, if it returns false, it is -ignored. This Lua code execution is not sandboxed. +option takes a string, which is interpreted as Lua expression. If the +expression evaluates as truthy, the profile is applied. If the expression +errors or evaluates as falsy, the profile is not applied. This Lua code +execution is not sandboxed. Any variables in condition expressions can reference properties. If an identifier is not already defined by Lua or mpv, it is interpreted as property. @@ -816,13 +817,13 @@ cause errors if used in expressions. These are logged in verbose mode, and the expression is considered to be false. Whenever a property referenced by a profile condition changes, the condition -is re-evaluated. If the return value of the condition changes from false or -error to true, the profile is applied. +is re-evaluated. If the return value of the condition changes from falsy or +error to truthy, the profile is applied. -This mechanism tries to "unapply" profiles once the condition changes from true -to false. If you want to use this, you need to set ``profile-restore`` for the -profile. Another possibility it to create another profile with an inverse -condition to undo the other profile. +This mechanism tries to "unapply" profiles once the condition changes from +truthy to falsy or error. If you want to use this, you need to set +``profile-restore`` for the profile. Another possibility it to create another +profile with an inverse condition to undo the other profile. Recursive profiles can be used. But it is discouraged to reference other conditional profiles in a conditional profile, since this can lead to tricky |