mirror of
https://github.com/mpv-player/mpv
synced 2025-01-24 00:23:27 +00:00
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.
This commit is contained in:
parent
fd5403cb40
commit
db167cd438
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user