From 943fa58204ac1e2669eec9cc9543c9d894f4bc2a Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Tue, 12 Oct 2021 13:26:18 +0200 Subject: [PATCH] Fixed #145 --- Makefile | 2 +- uwufetch.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1ff0e90..f2ce685 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ build: $(FILES) debug: @clear $(CC) $(CFLAGS_DEBUG) -o $(NAME) $(FILES) - UWUFETCH_CACHE_ENABLED=true ./uwufetch + ./uwufetch install: mkdir -p $(DESTDIR)$(PREFIX) $(DESTDIR)$(LIBDIR)/uwufetch $(DESTDIR)$(MANDIR) diff --git a/uwufetch.c b/uwufetch.c index c5a6907..c5c0655 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -128,14 +128,16 @@ int main(int argc, char *argv[]) char buffer[128]; sscanf(cache_env, "%[TRUEtrue1]", buffer); cache_enabled = (strcmp(buffer, "true") == 0 || strcmp(buffer, "TRUE") == 0 || strcmp(buffer, "1") == 0); - if (cache_enabled) { - // if no cache file found write to it - if (!read_cache()) { - get_info(); - write_cache(); + if (cache_enabled) + { + // if no cache file found write to it + if (!read_cache()) + { + get_info(); + write_cache(); } - print_cache(); - return 0; + print_cache(); + return 0; } } @@ -467,6 +469,8 @@ int read_cache() char line[256]; + int gpun = 0; + while (fgets(line, sizeof(line), cache_fp)) { sscanf(line, "user=%99[^\n]", user); @@ -475,6 +479,8 @@ int read_cache() sscanf(line, "host_model=%99[^\n]", host_model); sscanf(line, "kernel=%99[^\n]", kernel); sscanf(line, "cpu=%99[^\n]", cpu_model); + if (sscanf(line, "gpu=%99[^\n]", gpu_model[gpun]) != 0) + gpun++; sscanf(line, "screen_width=%i", &screen_width); sscanf(line, "screen_height=%i", &screen_height); sscanf(line, "shell=%99[^\n]", shell);