mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-26 07:55:58 +01:00
config: parse XDG_CURRENT_DESKTOP as a list
This commit is contained in:
parent
c60b2b6ca8
commit
feede20314
1 changed files with 31 additions and 13 deletions
|
@ -119,13 +119,32 @@ static char *get_config_path(void) {
|
||||||
prefix[0] = config_home;
|
prefix[0] = config_home;
|
||||||
prefix[1] = SYSCONFDIR "/xdg";
|
prefix[1] = SYSCONFDIR "/xdg";
|
||||||
|
|
||||||
const char *config[2];
|
char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
|
||||||
config[0] = getenv("XDG_CURRENT_DESKTOP");
|
char *config_fallback = "config";
|
||||||
config[1] = "config";
|
|
||||||
|
|
||||||
|
char *config_list = NULL;
|
||||||
for (size_t i = 0; i < 2; i++) {
|
for (size_t i = 0; i < 2; i++) {
|
||||||
for (size_t j = 0; j < 2; j++) {
|
if (xdg_current_desktop) {
|
||||||
char *path = config_path(prefix[i], config[j]);
|
config_list = strdup(xdg_current_desktop);
|
||||||
|
char *config = strtok(config_list, ":");
|
||||||
|
while (config) {
|
||||||
|
char *path = config_path(prefix[i], config);
|
||||||
|
if (!path) {
|
||||||
|
config = strtok(NULL, ":");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
logprint(TRACE, "config: trying config file %s", path);
|
||||||
|
if (file_exists(path)) {
|
||||||
|
free(config_list);
|
||||||
|
free(config_home_fallback);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
free(path);
|
||||||
|
config = strtok(NULL, ":");
|
||||||
|
}
|
||||||
|
free(config_list);
|
||||||
|
}
|
||||||
|
char *path = config_path(prefix[i], config_fallback);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +155,6 @@ static char *get_config_path(void) {
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
free(config_home_fallback);
|
free(config_home_fallback);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue