diff options
author | wm4 <wm4@nowhere> | 2015-02-13 22:28:44 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-02-13 22:28:44 +0100 |
commit | db167cd438b516371bc2a7b6e08a57f2054dc742 (patch) | |
tree | dc2d7926cffccd1e09d7a4be98d580526a339b46 | |
parent | fd5403cb404ca8fb30c2c6b1f415201bbce40d77 (diff) |
player: deprecate 'config' files (use mpv.conf), warn against clashes
Apparently there's at least one distro which ships a /etc/mpv/mpv.conf
file (mpv doesn't install such a file). This breaks config files named
'config' located in the user's mpv config directory, because mpv first
loads files named 'config' and then 'mpv.conf'. There is no mechanism
for putting files with different names into the same config path order.
(Even worse, that mpv.conf file only set an option to the default value.
Why do distros always do very stupid things?)
Print a warning on collisions.
Although using 'config' was well-supported, supporting both names is
starting to become messy, so deprecate 'config' and print a warning if
one is found.
At least we will be able to remove the whole mess once 'config' files
are ignored...
This also affects the osx-bundle, which intentionally used these not-so-
optimal semantics. Solve it in a different way. (Unfortunately with an
ifdef - it's not required, but having to explain everyone why mpv tries
to load a osx-bundle.mpv file on Linux and Windows would consume
energy.)
Closes #1569.
-rw-r--r-- | TOOLS/osxbundle/mpv.app/Contents/Resources/osx-bundle.conf (renamed from TOOLS/osxbundle/mpv.app/Contents/Resources/config) | 0 | ||||
-rw-r--r-- | player/configfiles.c | 32 |
2 files changed, 27 insertions, 5 deletions
diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/config b/TOOLS/osxbundle/mpv.app/Contents/Resources/osx-bundle.conf index ff78dfacf6..ff78dfacf6 100644 --- a/TOOLS/osxbundle/mpv.app/Contents/Resources/config +++ b/TOOLS/osxbundle/mpv.app/Contents/Resources/osx-bundle.conf diff --git a/player/configfiles.c b/player/configfiles.c index 0de1a7ba76..740484d7e2 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -46,13 +46,29 @@ #include "core.h" #include "command.h" -static void load_all_cfgfiles(struct MPContext *mpctx, char *section, - char *filename) +static int load_all_cfgfiles(struct MPContext *mpctx, char *section, + char *filename, bool bork) { char **cf = mp_find_all_config_files(NULL, mpctx->global, filename); - for (int i = 0; cf && cf[i]; i++) + int count = 0; + for (int i = 0; cf && cf[i]; i++) { + if (strcmp(filename, "config") == 0) { + MP_WARN(mpctx, "Loading %s - naming the mpv config files 'config' is " + "deprecated. Please rename it to 'mpv.conf'\n", cf[i]); + } + if (bork) { + MP_WARN(mpctx, "Warning: your system has a 'mpv.conf' somewhere " + "(check with -v), which will shadow 'config'. This " + "is probably unintended, and you should not mix " + "'config' and 'mpv.conf' files.\n" + "Just rename this file to mpv.conf.\n"); + bork = false; + } m_config_parse_config_file(mpctx->mconfig, cf[i], section, 0); + count++; + } talloc_free(cf); + return count; } #define SECT_ENCODE "encoding" @@ -84,8 +100,14 @@ void mp_parse_cfgfiles(struct MPContext *mpctx) talloc_free(cf); #endif - load_all_cfgfiles(mpctx, section, "config"); - load_all_cfgfiles(mpctx, section, "mpv.conf"); + // Stupid hack to set OSX bundle defaults, if applicable. (The file is only + // found if starting from the OSX bundle.) +#if HAVE_COCOA + load_all_cfgfiles(mpctx, section, "osx-bundle.conf"); +#endif + + int count = load_all_cfgfiles(mpctx, section, "mpv.conf", false); + load_all_cfgfiles(mpctx, section, "config", count > 0); if (encoding) m_config_set_profile(conf, m_config_add_profile(conf, SECT_ENCODE), 0); |