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

This commit is contained in:
8nlight 2023-08-06 12:00:32 +03:00
parent 72293603ac
commit 5c50c6cbd2

22
funcs.h
View File

@ -25,7 +25,6 @@ typedef struct {
} LOGO; } LOGO;
char *Os; char *Os;
char *Color;
LOGO Logo; LOGO Logo;
struct utsname Uts; struct utsname Uts;
@ -47,7 +46,6 @@ void Init(void) {
Os = GetOs(); Os = GetOs();
Logo = GetArt(); Logo = GetArt();
Color = Logo.color;
if (uname(&Uts) < 0) { if (uname(&Uts) < 0) {
fprintf(stderr, "WTF, uname dont work\n"); fprintf(stderr, "WTF, uname dont work\n");
exit(1); exit(1);
@ -58,28 +56,28 @@ void Init(void) {
void GetShell(void) { void GetShell(void) {
char *shell = getenv("SHELL"); char *shell = getenv("SHELL");
if (shell == NULL) { if (shell == NULL) {
printf("%s SHELL \033[37mNothing\033[0m", Color); printf("%s SHELL \033[37mNothing\033[0m", Logo.color);
return; return;
} }
char *splt = strrchr(shell, '/'); char *splt = strrchr(shell, '/');
if (splt != NULL) if (splt != NULL)
printf("%s SHELL \033[37m%s\033[0m", Color, splt + 1); printf("%s SHELL \033[37m%s\033[0m", Logo.color, splt + 1);
} }
void GetKernel(void) { void GetKernel(void) {
printf("%s KERNEL \033[37m%s\033[0m", Color, Uts.release); printf("%s KERNEL \033[37m%s\033[0m", Logo.color, Uts.release);
} }
void PrintOs(void) { void PrintOs(void) {
if (Os == NULL) { if (Os == NULL) {
printf("%s OS \033[37mUnknow\033[0m", Color); printf("%s OS \033[37mUnknow\033[0m", Logo.color);
return; return;
} }
printf("%s OS \033[37m%s\033[0m", Color, Os + strlen("PRETTY_NAME= ")); printf("%s OS \033[37m%s\033[0m", Logo.color, Os + strlen("PRETTY_NAME= "));
} }
@ -91,10 +89,10 @@ void GetUptime(void) {
int UptimeH = uptime.tv_sec / 3600; int UptimeH = uptime.tv_sec / 3600;
int UptimeM = (uptime.tv_sec / 60) - (uptime.tv_sec / 3600 * 60); int UptimeM = (uptime.tv_sec / 60) - (uptime.tv_sec / 3600 * 60);
printf("%s UPTIME \033[37m%dh %dm\033[0m", Color, UptimeH, UptimeM); printf("%s UPTIME \033[37m%dh %dm\033[0m", Logo.color, UptimeH, UptimeM);
#else #else
printf("%s UPTIME \033[37m0h 0m\033[0m", Color); printf("%s UPTIME \033[37m0h 0m\033[0m", Logo.color);
#endif #endif
} }
@ -102,18 +100,18 @@ void GetUptime(void) {
void GetUser(void) { void GetUser(void) {
struct passwd *pw = getpwuid(geteuid()); struct passwd *pw = getpwuid(geteuid());
printf("%s USER \033[37m%s\033[0m", Color, pw->pw_name); printf("%s USER \033[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[37m0", Color); printf("%s PKGS \033[37m0", Logo.color);
return; return;
} }
FILE *fp = popen(Logo.pkg_cmd, "r"); FILE *fp = popen(Logo.pkg_cmd, "r");
printf("%s PKGS \033[37m", Color); printf("%s PKGS \033[37m", Logo.color);
char ch; char ch;
while ((ch = fgetc(fp)) != '\n') while ((ch = fgetc(fp)) != '\n')