Загрузить файлы в «»

This commit is contained in:
8nlight 2023-08-20 21:59:40 +03:00
parent 69af8be271
commit a3f8da336a
2 changed files with 51 additions and 38 deletions

75
funcs.h
View File

@ -16,7 +16,6 @@
#define CLOCK CLOCK_MONOTONIC #define CLOCK CLOCK_MONOTONIC
#endif #endif
//Varables
typedef struct { typedef struct {
size_t size; size_t size;
char *color; char *color;
@ -53,7 +52,6 @@ void Init(void) {
} }
} }
void GetShell(void) { void GetShell(void) {
char *shell = getenv("SHELL"); char *shell = getenv("SHELL");
if (shell == NULL) { if (shell == NULL) {
@ -66,7 +64,6 @@ void GetShell(void) {
printf("%s SHELL \033[0;37m%s\033[0m", Logo.color, splt + 1); printf("%s SHELL \033[0;37m%s\033[0m", Logo.color, splt + 1);
} }
void GetKernel(void) { void GetKernel(void) {
printf("%s KERNEL \033[0;37m%s\033[0m", Logo.color, Uts.release); printf("%s KERNEL \033[0;37m%s\033[0m", Logo.color, Uts.release);
} }
@ -74,14 +71,13 @@ void GetKernel(void) {
void PrintOs(void) { void PrintOs(void) {
if (Os == NULL) { if (Os == NULL) {
printf("%s OS \033[0;37m%s\033[0m", Logo.color, Uts.sysname); printf("%s OS \033[0;37m%s\033[0m", Logo.color, Uts.sysname);
return; return;
} }
printf("%s OS \033[0;37m%s\033[0m", Logo.color, Os + strlen("PRETTY_NAME= ")); printf("%s OS \033[0;37m%s\033[0m", Logo.color, Os + strlen("PRETTY_NAME= "));
} }
void GetUptime(void) { void GetUptime(void) {
#ifdef CLOCK #ifdef CLOCK
struct timespec uptime; struct timespec uptime;
@ -98,13 +94,11 @@ void GetUptime(void) {
#endif #endif
} }
void GetUser(void) { void GetUser(void) {
struct passwd *pw = getpwuid(geteuid()); struct passwd *pw = getpwuid(geteuid());
printf("%s USER \033[0;37m%s\033[0m", Logo.color, pw->pw_name); printf("%s USER \033[0;37m%s\033[0m", Logo.color, pw->pw_name);
} }
void GetPkgs(void) { void GetPkgs(void) {
if (Logo.pkg_cmd == NULL) { if (Logo.pkg_cmd == NULL) {
printf("%s PKGS \033[0;37m0", Logo.color); printf("%s PKGS \033[0;37m0", Logo.color);
@ -121,7 +115,6 @@ void GetPkgs(void) {
pclose(fp); pclose(fp);
} }
char *GetOs(void) { char *GetOs(void) {
FILE *fp = fopen("/etc/os-release", "r"); FILE *fp = fopen("/etc/os-release", "r");
if (fp == NULL) if (fp == NULL)
@ -140,60 +133,68 @@ char *GetOs(void) {
return line; return line;
} }
} }
//EOF
free(line);
} }
return NULL; return NULL;
} }
void PrintColors(void) { void PrintColors(void) {
printf(" "); printf(" ");
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
printf("\033[1;3%dm● \033[0;3%dm● \033[0m", i, i); printf("\033[1;3%dm● \033[0;3%dm● \033[0m", i, i);
} }
void GetArch(void) { void GetArch(void) {
printf("%s ARCH \033[0;37m%s", Logo.color, Uts.machine); printf("%s ARCH \033[0;37m%s", Logo.color, Uts.machine);
} }
void Blank(void) { void Blank(void) {
return; return;
} }
LOGO GetArt(void) { LOGO GetArt(void) {
LOGO art; LOGO art;
//Else if (Os != NULL) {
art.size = sizeof(Unknow) / sizeof(char *); if (strstr(Os, "Debian")) {
art.pkg_cmd = NULL; art.size = sizeof(Debian) / sizeof(char *);
art.art = Unknow; art.pkg_cmd = "dpkg -l | tail -n+6 | wc -l";
art.color = "\033[1;35m"; art.art = Debian;
if (Os == NULL) art.color = "\033[0;31m";
return art; }
else if (strstr(Os, "Debian")) { else if (strstr(Os, "Void")) {
art.size = sizeof(Debian) / sizeof(char *); art.size = sizeof(Void) / sizeof(char *);
art.pkg_cmd = "dpkg -l | tail -n+6 | wc -l"; art.pkg_cmd = "xbps-query -l | wc -l";
art.art = Debian; art.art = Void;
art.color = "\033[0;31m"; art.color = "\033[0;32m";
}
else if (strstr(Os, "Alpine")) {
art.size = sizeof(Alpine) / sizeof(char *);
art.pkg_cmd = "grep 'P:' /lib/apk/db/installed | wc -l";
art.art = Alpine;
art.color = "\033[1;34m";
}
else if (strstr(Os, "Arch") || strstr(Os, "Artix")) {
art.size = sizeof(Arch) / sizeof(char *);
art.pkg_cmd = "pacman -Qq | wc -l";
art.art = Arch;
art.color = "\033[0;34m";
}
} }
else if (strstr(Os, "Void")) { else {
art.size = sizeof(Void) / sizeof(char *); art.size = sizeof(Unknow) / sizeof(char *);
art.pkg_cmd = "xbps-query -l | wc -l"; art.pkg_cmd = NULL;
art.art = Void; art.art = Unknow;
art.color = "\033[0;32m"; art.color = "\033[1;36m";
}
else if (strstr(Os, "Alpine")) {
art.size = sizeof(Alpine) / sizeof(char *);
art.pkg_cmd = "grep 'P:' /lib/apk/db/installed | wc -l";
art.art = Alpine;
art.color = "\033[1;34m";
} }
return art; return art;
} }

14
logos.h
View File

@ -25,10 +25,22 @@ char *Alpine[] = {
"\033[34m / \\ \\ ", "\033[34m / \\ \\ ",
"\033[34m/ \\ \\ ", "\033[34m/ \\ \\ ",
"\033[34m \\ ", "\033[34m \\ ",
" " " "
};
char *Arch[] = {
"\033[1;34m /\\ ",
"\033[1;34m / \\ ",
"\033[1;34m /\\ \\ ",
"\033[1;34m / \\ ",
"\033[1;34m / ,, \\ ",
"\033[1;34m / | | -\\ ",
"\033[1;34m/_-'' ''-_\\",
" "
}; };
char *Unknow[] = { char *Unknow[] = {
" ",
"\033[35m ___ ", "\033[35m ___ ",
"\033[35m (\033[0m..\033[35m | ", "\033[35m (\033[0m..\033[35m | ",
"\033[35m (\033[33m<> \033[35m| ", "\033[35m (\033[33m<> \033[35m| ",