mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 23:45:58 +01:00
Don't use ~/.config when XDG_CONFIG_HOME is set
According to the spec, ~/.config is a fallback used when XDG_CONFIG_HOME is unset. When the user has explicitly set XDG_CONFIG_HOME, we shouldn't try to use the fallback.
This commit is contained in:
parent
491cbb1cc6
commit
a18c298ad4
1 changed files with 9 additions and 5 deletions
|
@ -91,16 +91,20 @@ static char *get_config_path(void) {
|
||||||
char *config_home_fallback = calloc(size_fallback, sizeof(char));
|
char *config_home_fallback = calloc(size_fallback, sizeof(char));
|
||||||
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
|
snprintf(config_home_fallback, size_fallback, "%s/.config", home);
|
||||||
|
|
||||||
const char *prefix[3];
|
const char *config_home = getenv("XDG_CONFIG_HOME");
|
||||||
prefix[0] = getenv("XDG_CONFIG_HOME");
|
if (config_home == NULL || config_home[0] == '\0') {
|
||||||
prefix[1] = config_home_fallback;
|
config_home = config_home_fallback;
|
||||||
prefix[2] = SYSCONFDIR "/xdg";
|
}
|
||||||
|
|
||||||
|
const char *prefix[2];
|
||||||
|
prefix[0] = config_home;
|
||||||
|
prefix[1] = SYSCONFDIR "/xdg";
|
||||||
|
|
||||||
const char *config[2];
|
const char *config[2];
|
||||||
config[0] = getenv("XDG_CURRENT_DESKTOP");
|
config[0] = getenv("XDG_CURRENT_DESKTOP");
|
||||||
config[1] = "config";
|
config[1] = "config";
|
||||||
|
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 2; i++) {
|
||||||
for (size_t j = 0; j < 2; j++) {
|
for (size_t j = 0; j < 2; j++) {
|
||||||
char *path = config_path(prefix[i], config[j]);
|
char *path = config_path(prefix[i], config[j]);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
|
|
Loading…
Reference in a new issue