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

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;
char *Os;
char *Color;
LOGO Logo;
struct utsname Uts;
@ -47,7 +46,6 @@ void Init(void) {
Os = GetOs();
Logo = GetArt();
Color = Logo.color;
if (uname(&Uts) < 0) {
fprintf(stderr, "WTF, uname dont work\n");
exit(1);
@ -58,28 +56,28 @@ void Init(void) {
void GetShell(void) {
char *shell = getenv("SHELL");
if (shell == NULL) {
printf("%s SHELL \033[37mNothing\033[0m", Color);
printf("%s SHELL \033[37mNothing\033[0m", Logo.color);
return;
}
char *splt = strrchr(shell, '/');
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) {
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) {
if (Os == NULL) {
printf("%s OS \033[37mUnknow\033[0m", Color);
printf("%s OS \033[37mUnknow\033[0m", Logo.color);
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 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
printf("%s UPTIME \033[37m0h 0m\033[0m", Color);
printf("%s UPTIME \033[37m0h 0m\033[0m", Logo.color);
#endif
}
@ -102,18 +100,18 @@ void GetUptime(void) {
void GetUser(void) {
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) {
if (Logo.pkg_cmd == NULL) {
printf("%s PKGS \033[37m0", Color);
printf("%s PKGS \033[37m0", Logo.color);
return;
}
FILE *fp = popen(Logo.pkg_cmd, "r");
printf("%s PKGS \033[37m", Color);
printf("%s PKGS \033[37m", Logo.color);
char ch;
while ((ch = fgetc(fp)) != '\n')