Add support for $PREFIX

This commit is contained in:
Legend 2022-03-26 09:47:11 +03:00 committed by GitHub
parent d03cce5fb5
commit 23c38bcc22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -162,9 +162,15 @@ struct configuration parse_config(struct info* user_info) {
char homedir[512]; char homedir[512];
sprintf(homedir, "%s/.config/uwufetch/config", getenv("HOME")); sprintf(homedir, "%s/.config/uwufetch/config", getenv("HOME"));
config = fopen(homedir, "r"); config = fopen(homedir, "r");
if (!config) if (!config) {
if(getenv("PREFIX") != NULL) {
char prefixed_etc[512];
sprintf(prefixed_etc, "%s/etc/uwufetch/config", getenv("PREFIX"));
config = fopen(prefixed_etc, "r");
} else
config = fopen("/etc/uwufetch/config", "r"); config = fopen("/etc/uwufetch/config", "r");
} }
}
} else } else
config = fopen(user_info->config_directory, "r"); config = fopen(user_info->config_directory, "r");
if (config == NULL) return config_flags; // if config file does not exist, return the defaults if (config == NULL) return config_flags; // if config file does not exist, return the defaults