GetMem fixed, build fixed

This commit is contained in:
Your Name 2023-12-15 18:17:49 +03:00
parent 8a789784cc
commit e59cd1d2a0
4 changed files with 10 additions and 6 deletions

View File

@ -5,4 +5,4 @@ all:
$(CC) src/*.c -Iinclude -I. $(CFLAGS) -okfetch
clean:
rm kfetch
rm obj/* bin/*

View File

@ -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

View File

@ -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);

View File

@ -1,3 +1,4 @@
#define _MAIN_H
#include <stdio.h>
#include "fetch.h"
#include "config.h"