mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 21:31:52 +00:00
config: add a --config-dir option to force config directory
Useful for slave-mode like uses, and not as radical as --no-config.
This commit is contained in:
parent
2ea614ada6
commit
428ffb01cf
@ -557,6 +557,15 @@ OPTIONS
|
||||
It is advisable to use your graphics driver's color range option
|
||||
instead, if available.
|
||||
|
||||
``--config-dir=<path>``
|
||||
Force a different configuration directory. If this is set, the given
|
||||
directory is used to load configuration files, and all other configuration
|
||||
directories are ignored. This means the global mpv configuration directory
|
||||
as well as per-user directories are ignored, and overrides through
|
||||
environment variables (``MPV_HOME``) are also ignored.
|
||||
|
||||
Note that the ``--no-config`` option takes precedence over this option.
|
||||
|
||||
``--consolecontrols``, ``--no-consolecontrols``
|
||||
``--no-consolecontrols`` prevents the player from reading key events from
|
||||
standard input. Useful when reading data from standard input. This is
|
||||
@ -1420,6 +1429,8 @@ OPTIONS
|
||||
Files explicitly requested by command line options, like
|
||||
``--include`` or ``--use-filedir-conf``, will still be loaded.
|
||||
|
||||
Also see ``--config-dir``.
|
||||
|
||||
``--no-idx``
|
||||
Do not use index present in the file even if one is present.
|
||||
|
||||
|
@ -236,6 +236,8 @@ const m_option_t mp_opts[] = {
|
||||
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
#endif
|
||||
OPT_FLAG("config", load_config, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE),
|
||||
OPT_STRING("config-dir", force_configdir,
|
||||
CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE),
|
||||
OPT_STRINGLIST("reset-on-next-file", reset_options, CONF_GLOBAL),
|
||||
|
||||
#if HAVE_LUA
|
||||
|
@ -106,6 +106,7 @@ typedef struct MPOpts {
|
||||
int merge_files;
|
||||
int quiet;
|
||||
int load_config;
|
||||
char *force_configdir;
|
||||
int use_filedir_conf;
|
||||
int stream_cache_size;
|
||||
int stream_cache_def_size;
|
||||
|
@ -57,9 +57,14 @@ char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global,
|
||||
const char *filename)
|
||||
{
|
||||
struct MPOpts *opts = global->opts;
|
||||
|
||||
if (!opts->load_config)
|
||||
return NULL;
|
||||
|
||||
// Always force the local config dir.
|
||||
if (opts->force_configdir && opts->force_configdir[0])
|
||||
return mp_find_user_config_file(talloc_ctx, global, filename);
|
||||
|
||||
for (int i = 0; config_lookup_functions[i] != NULL; i++) {
|
||||
char *path = config_lookup_functions[i](talloc_ctx, global, filename);
|
||||
if (!path) continue;
|
||||
@ -76,9 +81,15 @@ char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global,
|
||||
const char *filename)
|
||||
{
|
||||
struct MPOpts *opts = global->opts;
|
||||
|
||||
if (!opts->load_config)
|
||||
return NULL;
|
||||
|
||||
if (opts->force_configdir && opts->force_configdir[0]) {
|
||||
return mp_path_join(talloc_ctx, bstr0(opts->force_configdir),
|
||||
bstr0(filename));
|
||||
}
|
||||
|
||||
char *homedir = getenv("MPV_HOME");
|
||||
char *configdir = NULL;
|
||||
char *result = NULL;
|
||||
@ -105,6 +116,10 @@ char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global,
|
||||
char *mp_find_global_config_file(void *talloc_ctx, struct mpv_global *global,
|
||||
const char *filename)
|
||||
{
|
||||
struct MPOpts *opts = global->opts;
|
||||
if (!opts->load_config || (opts->force_configdir && opts->force_configdir[0]))
|
||||
return NULL;
|
||||
|
||||
if (filename) {
|
||||
return mp_path_join(talloc_ctx, bstr0(MPLAYER_CONFDIR), bstr0(filename));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user