diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index 64de51d112c13..0fa61c35f768b 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -499,41 +499,62 @@ console controls. (Which makes it suitable for playing data piped to stdin.) The special argument ``--`` can be used to stop mpv from interpreting the following arguments as options. -When using the client API, you should strictly avoid using ``mpv_command_string`` +For paths passed to mpv suboptions (options that have multiple `:` and +`,`-separated values), the situation is further complicated by the need to +escape special characters. To work around this, the path can instead be wrapped +in the "fixed-length" syntax, e.g. ``%n%string_of_length_n`` (see above). + +When using the libmpv API, you should strictly avoid using ``mpv_command_string`` for invoking the ``loadfile`` command, and instead prefer e.g. ``mpv_command`` to avoid the need for filename escaping. -For paths passed to suboptions, the situation is further complicated by the -need to escape special characters. To work this around, the path can be -additionally wrapped in the fixed-length syntax, e.g. ``%n%string_of_length_n`` -(see above). +The same applies when you're using the scripting API, where you should avoid using +``mp.command``, and instead prefer using "separate parameter" APIs, such as +``mp.commandv`` and ``mp.command_native``. + +Some mpv options will interpret special meanings for paths starting with ``~``, +making it easy to dynamically find special directories, such as referring to the +current user's home directory or the mpv configuration directory. + +When using the special ``~`` prefix, there must always be a trailing ``/`` after +the special path prefix. In other words, ``~`` doesn't work, but ``~/`` will work. + +The following special paths/keywords are currently recognized: + +.. warning:: + + Beware that if ``--no-config`` is used, all of the "config directory"-based + paths (``~~/``, ``~~home/`` and ``~~global/``) will be empty strings. + + This means that ``~~home/`` would expand to an empty string, and that + sub-paths such as ``~~home/foo/bar"`` would expand to a relative path + (``foo/bar``), which may not be what you expected. + + Furthermore, any commands that search in config directories will fail + to find anything, since there won't be any directories to search in. -Some mpv options interpret paths starting with ``~``. -Currently, the prefix ``~~home/`` expands to the mpv configuration directory -(usually ``~/.config/mpv/``). -``~/`` expands to the user's home directory. (The trailing ``/`` is always -required.) The following paths are currently recognized: + Be sure that your scripts can handle these "no config" scenarios. ================ =============================================================== Name Meaning ================ =============================================================== -``~~/`` If the subpath exists in any of the mpv's config directories +``~/`` The current user's home directory (equivalent to ``~/`` and + ``$HOME/`` in terminal environments). +``~~/`` If the sub-path exists in any of mpv's config directories, then the path of the existing file/dir is returned. Otherwise this is equivalent to ``~~home/``. - Note that if --no-config is used ``~~/foobar`` will resolve to - ``foobar`` which can be unexpected. -``~/`` user home directory root (similar to shell, ``$HOME``) -``~~home/`` mpv config dir (for example ``~/.config/mpv/``) -``~~global/`` the global config path, if available (not on win32) -``~~osxbundle/`` the macOS bundle resource path (macOS only) -``~~desktop/`` the path to the desktop (win32, macOS) -``~~exe_dir/`` win32 only: the path to the directory containing the exe (for - config file purposes; ``$MPV_HOME`` overrides it) -``~~cache/`` the path to application cache data (``~/.cache/mpv/``) +``~~home/`` mpv's config dir (for example ``~/.config/mpv/``). +``~~global/`` The global config path (such as ``/etc/mpv``), if available + (not on win32). +``~~osxbundle/`` The macOS bundle resource path (macOS only). +``~~desktop/`` The path to the desktop (win32, macOS). +``~~exe_dir/`` The path to the directory containing ``mpv.exe`` (for config + file purposes, ``$MPV_HOME`` will override this) (win32 only). +``~~cache/`` The path to application cache data (``~/.cache/mpv/``). On some platforms, this will be the same as ``~~home/``. -``~~state/`` the path to application state data (``~/.local/state/mpv/``) +``~~state/`` The path to application state data (``~/.local/state/mpv/``). On some platforms, this will be the same as ``~~home/``. -``~~old_home/`` do not use +``~~old_home/`` Do not use. ================ ===============================================================