From 519d0b1e5d2a61fb404d6025ab049f31c4f98b00 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 2 Nov 2023 18:34:27 +0300 Subject: [PATCH] fix --- include/logo.h | 14 +++++++------- src/fetch.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/include/logo.h b/include/logo.h index 09c0c4f..acdeb04 100644 --- a/include/logo.h +++ b/include/logo.h @@ -43,13 +43,13 @@ char *Arch[] = { }; char *Android[] = { - "\033[32m ;, ,; ", - "\033[32m ';,.-----.,;' ", - "\033[32m ,' ', ", - "\033[32m / O O \\ ", - "\033[32m| | ", - "\033[32m'-----------------' ", - " ", + "\033[32m ;, ,; ", + "\033[32m ';,.-----.,;' ", + "\033[32m ,' ', ", + "\033[32m / O O \\ ", + "\033[32m| | ", + "\033[32m'-----------------' ", + " ", }; char *OpenBSD[] = { diff --git a/src/fetch.c b/src/fetch.c index 0276702..435f939 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -48,10 +48,37 @@ int GetOs(char *os_name, size_t len) { return 1; } +void SetArt(FETCH *fetch, size_t size, char *pkg_cmd, char **logo, char *color) { + fetch->logo_size = size; + fetch->logo = logo; + fetch->pkg_cmd = pkg_cmd; + fetch->color = color; +} + void GetArt(FETCH *fetch) { - fetch->color = "\033[36m"; - fetch->logo = Unknow; - fetch->logo_size = sizeof(Unknow) / sizeof(char *); + if (strstr(fetch->os_name, "Debian")) + SetArt(fetch, sizeof(Debian) / sizeof(char *), "dpkg -l | tail -n+6 | wc -l", Debian, "\033[0;31m"); + + else if (strstr(fetch->os_name, "Void")) + SetArt(fetch, sizeof(Void) / sizeof(char *), "xbps-query -l | wc -l", Void, "\033[0;32m"); + + else if (strstr(fetch->os_name, "Alpine")) + SetArt(fetch, sizeof(Alpine) / sizeof(char *), "grep 'P:' /lib/apk/db/installed | wc -l", Alpine, "\033[1;34m"); + + else if (strstr(fetch->os_name, "Arch") || strstr(fetch->os_name, "Artix")) + SetArt(fetch, sizeof(Arch) / sizeof(char *), "pacman -Qq | wc -l", Arch, "\033[0;34m"); + + else if (strstr(fetch->os_name, "PlainOs")) + SetArt(fetch, sizeof(PlainOs) / sizeof(char *), NULL, PlainOs, "\033[37m"); + + else if (strstr(fetch->os_name, "OpenBSD")) + SetArt(fetch, sizeof(OpenBSD) / sizeof(char *), "/bin/ls -1 /var/db/pkg/ | wc -l | tr -d ' '", OpenBSD, "\033[1;33m"); + + else if (!chdir("/system")) + SetArt(fetch, sizeof(Android) / sizeof(char *), "dpkg -l | tail -n+6 | wc -l", Android, "\033[32m"); + + else + SetArt(fetch, sizeof(Unknow) / sizeof(char *), NULL, Unknow, "\033[1;36m"); } void GetKernel(const char *title, const FETCH fetch) {