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

@ -20,8 +20,9 @@ static PARAMETR CONFIG[] = {
{" ARCH ", GetArch}, {" ARCH ", GetArch},
{" SHELL ", GetShell}, {" SHELL ", GetShell},
{" PKGS ", GetPkg}, {" PKGS ", GetPkg},
{" RAM ", GetMem},
{" ", Blank}, {" ", Blank},
{" ", PrintColors} {" COLORS ", PrintColors}
}; };
#endif #endif

View File

@ -36,5 +36,6 @@ int GetUptime(const char *title, const FETCH fetch);
int GetArch(const char *title, const FETCH fetch); int GetArch(const char *title, const FETCH fetch);
int GetShell(const char *title, const FETCH fetch); int GetShell(const char *title, const FETCH fetch);
int GetPkg(const char *title, const FETCH fetch); int GetPkg(const char *title, const FETCH fetch);
int GetMem(const char *title, const FETCH fetch);
#endif #endif

View File

@ -2,6 +2,7 @@
#define _LOGOS_H #define _LOGOS_H
char *Debian[] = { char *Debian[] = {
" ",
"\033[31m _____ ", "\033[31m _____ ",
"\033[31m / __ \\ ", "\033[31m / __ \\ ",
"\033[31m| / | ", "\033[31m| / | ",
@ -12,6 +13,7 @@ char *Debian[] = {
}; };
char *Void[] = { char *Void[] = {
" ",
"\033[32m _\033[36m________ ", "\033[32m _\033[36m________ ",
"\033[32m / \\\033[36m\\ _ \\ ", "\033[32m / \\\033[36m\\ _ \\ ",
"\033[32m| /\\\033[36m\\ \\ | ", "\033[32m| /\\\033[36m\\ \\ | ",
@ -22,6 +24,7 @@ char *Void[] = {
}; };
char *Alpine[] = { char *Alpine[] = {
" ",
"\033[34m /\\ /\\ ", "\033[34m /\\ /\\ ",
"\033[34m / \\ \\ ", "\033[34m / \\ \\ ",
"\033[34m / \\ \\ ", "\033[34m / \\ \\ ",
@ -32,6 +35,7 @@ char *Alpine[] = {
}; };
char *Arch[] = { char *Arch[] = {
" ",
"\033[1;34m /\\ ", "\033[1;34m /\\ ",
"\033[1;34m / \\ ", "\033[1;34m / \\ ",
"\033[1;34m /\\ \\ ", "\033[1;34m /\\ \\ ",
@ -43,6 +47,7 @@ char *Arch[] = {
}; };
char *Android[] = { char *Android[] = {
" ",
"\033[32m ;, ,; ", "\033[32m ;, ,; ",
"\033[32m ';,.-----.,;' ", "\033[32m ';,.-----.,;' ",
"\033[32m ,' ', ", "\033[32m ,' ', ",
@ -53,6 +58,7 @@ char *Android[] = {
}; };
char *OpenBSD[] = { char *OpenBSD[] = {
" ",
"\033[1;33m _____ ", "\033[1;33m _____ ",
"\033[1;33m \\- -/ ", "\033[1;33m \\- -/ ",
"\033[1;33m \\_/ \\ ", "\033[1;33m \\_/ \\ ",
@ -64,6 +70,7 @@ char *OpenBSD[] = {
}; };
char *PlainOs[] = { char *PlainOs[] = {
" ",
" (\\(\\ ", " (\\(\\ ",
" j . .) ", " j . .) ",
" | ° ! ", " | ° ! ",
@ -73,12 +80,13 @@ char *PlainOs[] = {
}; };
char *Ubuntu[] = { char *Ubuntu[] = {
"\033[1;32m _ ", " ",
"\033[1;32m ---(_) ", "\033[1;33m _ ",
"\033[1;32m _/ --- \\ ", "\033[1;33m ---(_) ",
"\033[1;32m(_) | | ", "\033[1;33m _/ --- \\ ",
"\033[1;32m \\ --- _/ ", "\033[1;33m(_) | | ",
"\033[1;32m ---(_) ", "\033[1;33m \\ --- _/ ",
"\033[1;33m ---(_) ",
" ", " ",
}; };

View File

@ -5,6 +5,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#if defined(__LINUX__) || defined(__ANDROID__)
#include <sys/sysinfo.h>
#endif
#include "fetch.h" #include "fetch.h"
#include "config.h" #include "config.h"
#include "logo.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"); 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")) 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")) else if (!chdir("/system"))
SetArt(fetch, sizeof(Android), "dpkg -l | tail -n+6 | wc -l | tr -d ' '", Android, "\033[32m"); 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); pclose(fp);
return 0; 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;
}