From 47b22c9ffafd7de4c030b148ff2c86eb2d3ec940 Mon Sep 17 00:00:00 2001 From: 8nlight <8nlight@disroot.org> Date: Thu, 19 Oct 2023 14:02:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- funcs.h | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/funcs.h b/funcs.h index 2becbf7..e80a3a3 100644 --- a/funcs.h +++ b/funcs.h @@ -43,8 +43,9 @@ char *GetOs(void); void PrintColors(void); void GetArch(void); void Blank(void); -LOGO GetArt(void); +void SetArt(LOGO *art, size_t size, char *pkg_cmd, char **logo, char *color); +LOGO GetArt(void); void Init(void) { Os = GetOs(); @@ -147,7 +148,7 @@ char *GetOs(void) { } void PrintColors(void) { - for (int i = 0; i < 7; i++) + for (int i = 1; i < 7; i++) printf("\033[1;3%dm● \033[0;3%dm● \033[0m", i, i); } @@ -172,45 +173,32 @@ void Blank(void) { return; } +void SetArt(LOGO *art, size_t size, char *pkg_cmd, char **logo, char *color) { + art->size = size; + art->pkg_cmd = pkg_cmd; + art->art = logo; + art->color = color; +} + LOGO GetArt(void) { LOGO art; if (Os != NULL) { - if (strstr(Os, "Debian")) { - art.size = sizeof(Debian) / sizeof(char *); - art.pkg_cmd = "dpkg -l | tail -n+6 | wc -l"; - art.art = Debian; - art.color = "\033[0;31m"; - } + if (strstr(Os, "Debian")) + SetArt(&art, sizeof(Debian) / sizeof(char *), "dpkg -l | tail -n+6 | wc -l", Debian, "\033[0;31m"); - else if (strstr(Os, "Void")) { - art.size = sizeof(Void) / sizeof(char *); - art.pkg_cmd = "xbps-query -l | wc -l"; - art.art = Void; - art.color = "\033[0;32m"; - } + else if (strstr(Os, "Void")) + SetArt(&art, sizeof(Void) / sizeof(char *), "xbps-query -l | wc -l", Void, "\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, "Alpine")) + SetArt(&art, sizeof(Alpine) / sizeof(char *), "grep 'P:' /lib/apk/db/installed | wc -l", Alpine, "\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, "Arch") || strstr(Os, "Artix")) + SetArt(&art, sizeof(Arch) / sizeof(char *), "pacman -Qq | wc -l", Arch, "\033[0;34m"); } - else { - art.size = sizeof(Unknow) / sizeof(char *); - art.pkg_cmd = NULL; - art.art = Unknow; - art.color = "\033[1;36m"; - } + else + SetArt(&art, sizeof(Unknow) / sizeof(char *), NULL, Unknow, "\033[1;36m"); return art; }