diff --git a/Makefile b/Makefile index a170b34..adc568a 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,4 @@ all: $(CC) src/*.c -Iinclude -I. $(CFLAGS) -okfetch clean: - rm kfetch + rm obj/* bin/* diff --git a/config.h b/config.h index ec3b354..1d39110 100644 --- a/config.h +++ b/config.h @@ -12,7 +12,8 @@ typedef struct { #define FONT_COLOR "\033[37m" #define PC_CHAR "%" -static PARAMETR CONFIG[] = { +#ifdef _MAIN_H +PARAMETR CONFIG[] = { {" OS ", PrintOs}, {" KERNEL ", GetKernel}, {" USER ", GetUser}, @@ -26,3 +27,5 @@ static PARAMETR CONFIG[] = { }; #endif + +#endif diff --git a/src/fetch.c b/src/fetch.c index eddd4ef..9d5ff1c 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -180,15 +180,15 @@ int GetPkg(const char *title, const FETCH fetch) { } int GetMem(const char *title, const FETCH fetch) { - unsigned int free = 0, cache = 0, total = 0, unused; - UNUSED(unused); - FILE *fp = fopen("/proc/meminfo", "r"); if (fp == NULL) return 1; - fscanf(fp, "MemTotal: %u kB\nMemFree: %u kB\nMemAvailable: %u kB\nBuffers: %u kB\nCached: %u kB", &total, &free, &unused, &unused, &cache); + unsigned int free = 0, cache = 0, total = 0, unused; + if (fscanf(fp, "MemTotal: %u kB\nMemFree: %u kB\nMemAvailable: %u kB\nBuffers: %u kB\nCached: %u kB", &total, &free, &unused, &unused, &cache) < 0) + return 1; + UNUSED(unused); printf("%s%s%s%umb / %umb", fetch.color, title, fetch.font_color, (free + cache) / 1024, total / 1024); fclose(fp); diff --git a/src/main.c b/src/main.c index 5e2e611..58d56a0 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,4 @@ +#define _MAIN_H #include #include "fetch.h" #include "config.h"