diff --git a/docs/retroarch.1 b/docs/retroarch.1 index 2be97c71f7..4f7661c38d 100644 --- a/docs/retroarch.1 +++ b/docs/retroarch.1 @@ -73,7 +73,7 @@ When loading a rom from stdin, the path must be a full path, however. If a config cannot be found when using directory path, the default config path will be used instead. .IP -Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. Then it will try $HOME/.retroarch.cfg. Last, it will try /etc/retroarch.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden. +Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. If $XDG_CONFIG_HOME is not defined, it is assumed to be $HOME/.config as per specification. Then it will try $HOME/.retroarch.cfg. Last, it will try /etc/retroarch.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden. .IP Windows will look in retroarch.cfg in same folder where retroarch.exe resides. diff --git a/retroarch.c b/retroarch.c index 7269d089f9..dc3345e5d2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -569,10 +569,8 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig #ifdef _WIN32 #define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe." -#elif defined(__APPLE__) -#define RARCH_DEFAULT_CONF_PATH_STR " Defaults to $HOME/.retroarch.cfg." #else -#define RARCH_DEFAULT_CONF_PATH_STR " Defaults to $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\tor $HOME/.retroarch.cfg, if $XDG_CONFIG_HOME is not defined." +#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg." #endif #include "config.features.h" diff --git a/settings.c b/settings.c index 4e6576e845..7344eba6d8 100644 --- a/settings.c +++ b/settings.c @@ -329,36 +329,37 @@ static config_file_t *open_default_config_file(void) conf = config_file_new(conf_path); } } -#elif defined(__APPLE__) - char conf_path[PATH_MAX]; - const char *home = getenv("HOME"); - if (home) - { - snprintf(conf_path, sizeof(conf_path), "%s/.retroarch.cfg", home); - conf = config_file_new(conf_path); - } - if (!conf) - conf = config_file_new("/etc/retroarch.cfg"); #elif !defined(__CELLOS_LV2__) && !defined(_XBOX) char conf_path[PATH_MAX]; - const char *xdg = getenv("XDG_CONFIG_HOME"); - if (!xdg) - RARCH_WARN("XDG_CONFIG_HOME is not defined. Will look for config in $HOME/.retroarch.cfg ...\n"); - + const char *xdg = getenv("XDG_CONFIG_HOME"); const char *home = getenv("HOME"); + + // XDG_CONFIG_HOME falls back to $HOME/.config. if (xdg) - { snprintf(conf_path, sizeof(conf_path), "%s/retroarch/retroarch.cfg", xdg); + else if (home) + snprintf(conf_path, sizeof(conf_path), "%s/.config/retroarch/retroarch.cfg", home); + + if (xdg || home) + { + RARCH_LOG("Looking for config in: \"%s\".\n", conf_path); conf = config_file_new(conf_path); } - else if (home) + + // Fallback to $HOME/.retroarch.cfg. + if (!conf && home) { snprintf(conf_path, sizeof(conf_path), "%s/.retroarch.cfg", home); + RARCH_LOG("Looking for config in: \"%s\".\n", conf_path); conf = config_file_new(conf_path); } - // Try this as a last chance... + + // Try this as a last chance ... if (!conf) + { conf = config_file_new("/etc/retroarch.cfg"); + RARCH_LOG("Looking for config in: \"/etc/retroarch.cfg\".\n"); + } #endif return conf;