fix
This commit is contained in:
parent
b88f882a17
commit
18697ea260
18
config.h
18
config.h
@ -13,15 +13,15 @@ typedef struct {
|
|||||||
#define PC_CHAR "%"
|
#define PC_CHAR "%"
|
||||||
|
|
||||||
static PARAMETR CONFIG[] = {
|
static PARAMETR CONFIG[] = {
|
||||||
{"Os ", PrintOs},
|
{" OS ", PrintOs},
|
||||||
{"Krnl ", GetKernel},
|
{" KERNEL ", GetKernel},
|
||||||
{"User ", GetUser},
|
{" USER ", GetUser},
|
||||||
{"Uptm ", GetUptime},
|
{" UPTIME ", GetUptime},
|
||||||
{"Arch ", GetArch},
|
{" ARCH ", GetArch},
|
||||||
{"Shll ", GetShell},
|
{" SHELL ", GetShell},
|
||||||
{"Pkgs ", GetPkg},
|
{" PKGS ", GetPkg},
|
||||||
{" ", Blank},
|
{"", Blank},
|
||||||
{" ", PrintColors}
|
{"", PrintColors}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
23
src/fetch.c
23
src/fetch.c
@ -47,7 +47,7 @@ int GetOs(char *os_name, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetArt(FETCH *fetch, size_t size, char *pkg_cmd, char **logo, char *color) {
|
void SetArt(FETCH *fetch, size_t size, char *pkg_cmd, char **logo, char *color) {
|
||||||
fetch->logo_size = size;
|
fetch->logo_size = size / sizeof(char *);
|
||||||
fetch->logo = logo;
|
fetch->logo = logo;
|
||||||
fetch->pkg_cmd = pkg_cmd;
|
fetch->pkg_cmd = pkg_cmd;
|
||||||
fetch->color = color;
|
fetch->color = color;
|
||||||
@ -55,28 +55,28 @@ void SetArt(FETCH *fetch, size_t size, char *pkg_cmd, char **logo, char *color)
|
|||||||
|
|
||||||
void GetArt(FETCH *fetch) {
|
void GetArt(FETCH *fetch) {
|
||||||
if (strstr(fetch->os_name, "Debian"))
|
if (strstr(fetch->os_name, "Debian"))
|
||||||
SetArt(fetch, sizeof(Debian) / sizeof(char *), "dpkg -l | tail -n+6 | wc -l", Debian, "\033[0;31m");
|
SetArt(fetch, sizeof(Debian), "dpkg -l | tail -n+6 | wc -l", Debian, "\033[0;31m");
|
||||||
|
|
||||||
else if (strstr(fetch->os_name, "Void"))
|
else if (strstr(fetch->os_name, "Void"))
|
||||||
SetArt(fetch, sizeof(Void) / sizeof(char *), "xbps-query -l | wc -l", Void, "\033[0;32m");
|
SetArt(fetch, sizeof(Void), "xbps-query -l | wc -l", Void, "\033[0;32m");
|
||||||
|
|
||||||
else if (strstr(fetch->os_name, "Alpine"))
|
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");
|
SetArt(fetch, sizeof(Alpine), "grep 'P:' /lib/apk/db/installed | wc -l", Alpine, "\033[1;34m");
|
||||||
|
|
||||||
else if (strstr(fetch->os_name, "Arch") || strstr(fetch->os_name, "Artix"))
|
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");
|
SetArt(fetch, sizeof(Arch), "pacman -Qq | wc -l", Arch, "\033[0;34m");
|
||||||
|
|
||||||
else if (strstr(fetch->os_name, "PlainOs"))
|
else if (strstr(fetch->os_name, "PlainOs"))
|
||||||
SetArt(fetch, sizeof(PlainOs) / sizeof(char *), NULL, PlainOs, "\033[37m");
|
SetArt(fetch, sizeof(PlainOs), NULL, PlainOs, "\033[37m");
|
||||||
|
|
||||||
else if (strstr(fetch->os_name, "OpenBSD"))
|
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");
|
SetArt(fetch, sizeof(OpenBSD), "/bin/ls -1 /var/db/pkg/ | wc -l | tr -d ' '", OpenBSD, "\033[1;33m");
|
||||||
|
|
||||||
else if (!chdir("/system"))
|
else if (!chdir("/system"))
|
||||||
SetArt(fetch, sizeof(Android) / sizeof(char *), "dpkg -l | tail -n+6 | wc -l", Android, "\033[32m");
|
SetArt(fetch, sizeof(Android), "dpkg -l | tail -n+6 | wc -l", Android, "\033[32m");
|
||||||
|
|
||||||
else
|
else
|
||||||
SetArt(fetch, sizeof(Unknow) / sizeof(char *), NULL, Unknow, "\033[1;36m");
|
SetArt(fetch, sizeof(Unknow), NULL, Unknow, "\033[1;36m");
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetKernel(const char *title, const FETCH fetch) {
|
int GetKernel(const char *title, const FETCH fetch) {
|
||||||
@ -90,8 +90,7 @@ int PrintOs(const char *title, const FETCH fetch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PrintColors(const char *title, const FETCH fetch) {
|
int PrintColors(const char *title, const FETCH fetch) {
|
||||||
UNUSED(title);
|
printf("%s%s%s", fetch.color, title, fetch.font_color);
|
||||||
UNUSED(fetch);
|
|
||||||
|
|
||||||
for (int i = 1; i < 7; i++)
|
for (int i = 1; i < 7; i++)
|
||||||
printf("\033[1;3%dm%s\033[0m \033[0;3%dm%s\033[0m ", i, PC_CHAR, i, PC_CHAR);
|
printf("\033[1;3%dm%s\033[0m \033[0;3%dm%s\033[0m ", i, PC_CHAR, i, PC_CHAR);
|
||||||
@ -102,7 +101,7 @@ int PrintColors(const char *title, const FETCH fetch) {
|
|||||||
int Blank(const char *title, const FETCH fetch) {
|
int Blank(const char *title, const FETCH fetch) {
|
||||||
UNUSED(title);
|
UNUSED(title);
|
||||||
UNUSED(fetch);
|
UNUSED(fetch);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetUser(const char *title, const FETCH fetch) {
|
int GetUser(const char *title, const FETCH fetch) {
|
||||||
|
15
src/main.c
15
src/main.c
@ -5,26 +5,19 @@
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
FETCH fetch = Init();
|
FETCH fetch = Init();
|
||||||
|
|
||||||
/* Function failed */
|
|
||||||
int flag = 0;
|
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < sizeof(CONFIG) / sizeof(PARAMETR); i++) {
|
for (i = 0; i < sizeof(CONFIG) / sizeof(PARAMETR); i++) {
|
||||||
if (i < fetch.logo_size && !flag)
|
if (i < fetch.logo_size)
|
||||||
printf("%s", fetch.logo[i]);
|
printf("%s", fetch.logo[i]);
|
||||||
|
|
||||||
if (i >= fetch.logo_size && !flag)
|
if (i >= fetch.logo_size)
|
||||||
printf("%s", fetch.logo[fetch.logo_size - 1]);
|
printf("%s", fetch.logo[fetch.logo_size - 1]);
|
||||||
|
|
||||||
if (!CONFIG[i].func(CONFIG[i].title, fetch)) {
|
if (!CONFIG[i].func(CONFIG[i].title, fetch))
|
||||||
flag = 0;
|
|
||||||
printf("\033[0m\n");
|
printf("\033[0m\n");
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
else
|
||||||
flag = 1;
|
|
||||||
printf("\033[0m");
|
printf("\033[0m");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < fetch.logo_size; i++)
|
for (; i < fetch.logo_size; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user