Merge pull request #194 from FoIIower/etc_dir-patch

[OS-SUPPORT] Fix ETC_DIR for unrooted Android/Termux
This commit is contained in:
TheDarkBug 2022-03-26 10:51:09 +01:00 committed by GitHub
commit edc3ac96ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -13,6 +13,7 @@ ifeq ($(PLATFORM), Linux)
MANDIR = share/man/man1 MANDIR = share/man/man1
ifeq ($(shell uname -o), Android) ifeq ($(shell uname -o), Android)
DESTDIR = /data/data/com.termux/files/usr DESTDIR = /data/data/com.termux/files/usr
ETC_DIR = $(DESTDIR)/etc
endif endif
else ifeq ($(PLATFORM), Darwin) else ifeq ($(PLATFORM), Darwin)
PREFIX = local/bin PREFIX = local/bin

View file

@ -162,8 +162,14 @@ 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) {
config = fopen("/etc/uwufetch/config", "r"); 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");
}
} }
} else } else
config = fopen(user_info->config_directory, "r"); config = fopen(user_info->config_directory, "r");