GetMem add

This commit is contained in:
Your Name 2023-12-15 17:02:25 +03:00
parent ede4cea77c
commit 14fce9786e
4 changed files with 39 additions and 8 deletions

View file

@ -5,6 +5,11 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/utsname.h>
#if defined(__LINUX__) || defined(__ANDROID__)
#include <sys/sysinfo.h>
#endif
#include "fetch.h"
#include "config.h"
#include "logo.h"
@ -73,7 +78,7 @@ void GetArt(FETCH *fetch) {
SetArt(fetch, sizeof(OpenBSD), "/bin/ls -1 /var/db/pkg/ | wc -l | tr -d ' '", OpenBSD, "\033[1;33m");
else if (strstr(fetch->os_name, "Ubuntu"))
SetArt(fetch, sizeof(Ubuntu), "dpkg -l | tail -n+6 | wc -l | tr -d ' '", Ubuntu, "\033[1;32m");
SetArt(fetch, sizeof(Ubuntu), "dpkg -l | tail -n+6 | wc -l | tr -d ' '", Ubuntu, "\033[1;33m");
else if (!chdir("/system"))
SetArt(fetch, sizeof(Android), "dpkg -l | tail -n+6 | wc -l | tr -d ' '", Android, "\033[32m");
@ -175,3 +180,19 @@ int GetPkg(const char *title, const FETCH fetch) {
pclose(fp);
return 0;
}
int GetMem(const char *title, const FETCH fetch) {
#if defined(__LINUX__) || defined(__ANDROID__)
struct sysinfo sinfo;
if (sysinfo(&sinfo) < 0)
return 1;
printf("%s%s%s%lumb / %lumb", fetch.color, title, fetch.font_color, sinfo.freeram / 1048576, sinfo.totalram / 1048576);
#else
printf("%s%s%s0mb / 0mb", fetch.color, title, fetch.font_color);
#endif
return 0;
}