From 410f8ec2e8c2cf21bc353ddbc71cd47fd38650d7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 3 Jan 2024 15:24:33 +0300 Subject: [PATCH] fixed --- config.h | 1 - src/main.c | 31 ++++++++++--------------------- themes/default.h | 1 - themes/fira.h | 1 - themes/mini.h | 32 ++++++++++++++++++++++++++++++++ themes/tree.h | 1 - 6 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 themes/mini.h diff --git a/config.h b/config.h index 86cafb3..8d93cf3 100644 --- a/config.h +++ b/config.h @@ -11,7 +11,6 @@ typedef struct { /* Config, EDIT THERE */ #define COLORS "\033[31m<> \033[32m<> \033[33m<> \033[34m<> \033[35m<> \033[36m<>\033[0m" #define FONT_COLOR "\033[1;37m" -#define PC_CHAR "<>" /* #define PRINT_TOTAL_MEM */ /* #define PRINT_USER_MEM */ diff --git a/src/main.c b/src/main.c index 2652bd2..0433281 100644 --- a/src/main.c +++ b/src/main.c @@ -34,41 +34,30 @@ int main(int argc, char **argv) { } int flag = 0; - size_t i = 0; - for (i = 0; i < sizeof(CONFIG) / sizeof(PARAMETR); i++) { - /* Logo print */ - if (i < fetch.logo_size && !flag && !l_flag) - printf("%s", fetch.logo[i]); + size_t j = 0; + for (size_t i = 0; i < sizeof(CONFIG) / sizeof(PARAMETR); i++) { + /* Print ascii logo */ + if (j < fetch.logo_size && !flag && !l_flag) + printf("%s", fetch.logo[j]); - else if (i >= fetch.logo_size && !flag && !l_flag) + else if (j >= fetch.logo_size && !flag && !l_flag) printf("%s", fetch.logo[fetch.logo_size - 1]); - /* Strip */ - char *title = CONFIG[i].title; - if (l_flag) { - size_t len = strlen(title); - for (size_t i = 0; i < len; i++) { - if (title[0] != ' ') - break; - - title++; - } - } - /* Function exec */ - if (CONFIG[i].func(title, fetch)) { + if (CONFIG[i].func(CONFIG[i].title, fetch)) { flag = 1; printf("\033[0m"); } else { flag = 0; + j++; printf("\033[0m\n"); } } - for (; i < fetch.logo_size; i++) - printf("%s\n", fetch.logo[i]); + for (; j < fetch.logo_size; j++) + printf("%s\n", fetch.logo[j]); printf("\033[0m"); return 0; diff --git a/themes/default.h b/themes/default.h index 86cafb3..8d93cf3 100644 --- a/themes/default.h +++ b/themes/default.h @@ -11,7 +11,6 @@ typedef struct { /* Config, EDIT THERE */ #define COLORS "\033[31m<> \033[32m<> \033[33m<> \033[34m<> \033[35m<> \033[36m<>\033[0m" #define FONT_COLOR "\033[1;37m" -#define PC_CHAR "<>" /* #define PRINT_TOTAL_MEM */ /* #define PRINT_USER_MEM */ diff --git a/themes/fira.h b/themes/fira.h index 1ebe6e6..6cf9da1 100644 --- a/themes/fira.h +++ b/themes/fira.h @@ -11,7 +11,6 @@ typedef struct { /* Config, EDIT THERE */ #define COLORS " \033[31mx \033[32mx \033[33mx \033[34mx \033[35mx \033[0m" #define FONT_COLOR "\033[1;37m" -#define PC_CHAR "<>" /* #define PRINT_TOTAL_MEM */ /* #define PRINT_USER_MEM */ diff --git a/themes/mini.h b/themes/mini.h new file mode 100644 index 0000000..12beb84 --- /dev/null +++ b/themes/mini.h @@ -0,0 +1,32 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +#include "fetch.h" + +typedef struct { + char *title; + int (*func)(const char *title, const FETCH fetch); +} PARAMETR; + +/* Config, EDIT THERE */ +#define COLORS " \033[31mx \033[32mx \033[33mx \033[34mx \033[35mx \033[0m" +#define FONT_COLOR "\033[1;37m" + +/* #define PRINT_TOTAL_MEM */ +/* #define PRINT_USER_MEM */ +#define PRINT_USED_AND_TOTAL_MEM + +#ifdef _MAIN_H +PARAMETR CONFIG[] = { + {" ", Blank}, + {" arch ", GetArch}, + {" upt ", GetUptime}, + {" pkgs ", GetPkg}, + {" os ", PrintOs}, + {" ", Blank}, + {COLORS, Blank} +}; + +#endif + +#endif diff --git a/themes/tree.h b/themes/tree.h index aa210c6..d18b871 100644 --- a/themes/tree.h +++ b/themes/tree.h @@ -11,7 +11,6 @@ typedef struct { /* Config, EDIT THERE */ #define COLORS " \033[41;31m++ \033[42;32m++ \033[43;33m++ \033[44;34m++ \033[45;35m++ \033[46;36m++\033[0m" #define FONT_COLOR "\033[1;37m" -#define PC_CHAR "<>" /* #define PRINT_TOTAL_MEM */ /* #define PRINT_USER_MEM */