This commit is contained in:
Your Name 2024-09-09 14:21:26 +03:00
parent 078b018ebc
commit ce965804d3
5 changed files with 45 additions and 10 deletions

View File

@ -16,10 +16,14 @@ typedef struct {
} FETCH;
struct par {
/* Text before */
char *str0;
/* Text after */
char *str1;
/* Command */
char *str2;
int error_flag;
};
typedef struct {

BIN
kfetch Executable file

Binary file not shown.

View File

@ -219,7 +219,7 @@ int GetModel(struct par par, const FETCH fetch) {
if (ptr != NULL)
*ptr = '\0';
printf("%s%.25s", FONT_COLOR, model_buffer);
printf("%s%s", FONT_COLOR, model_buffer);
}
fclose(fp);

View File

@ -6,7 +6,7 @@
#include "config.h"
int main(int argc, char **argv) {
unsigned int l_flag = 0;
char l_flag = 0;
char *d_flag = NULL;
int opt;
@ -22,7 +22,7 @@ int main(int argc, char **argv) {
case 'h':
default:
printf("kfetch [-hld]\n\t-h Help\n\t-l Dont print logo\n\t-d NAME\n");
printf("kfetch [-hld]\n\t-h Help\n\t-l Dont print logo\n\t-d STR Set STR as distro name\n");
return 0;
}
}
@ -33,9 +33,11 @@ int main(int argc, char **argv) {
GetArt(&fetch, 0);
}
int flag = 0;
size_t j = 0;
for (size_t i = 0; i < sizeof(CONFIG) / sizeof(PARAMETR); i++) {
if (CONFIG[i].func == NULL)
break;
/* Print ascii logo */
if (j < fetch.logo_size && !l_flag)
printf("%s", fetch.logo[j]);
@ -45,13 +47,10 @@ int main(int argc, char **argv) {
/* Function exec */
printf("%s%s", fetch.color, CONFIG[i].par.str0);
if (CONFIG[i].func(CONFIG[i].par, fetch)) {
flag = 1;
if (CONFIG[i].func(CONFIG[i].par, fetch))
printf("%s%s", FONT_COLOR, ON_ERROR_STR);
}
else {
flag = 0;
if (CONFIG[i].par.str1 != NULL)
printf(CONFIG[i].par.str1, fetch.color);
}
@ -60,7 +59,7 @@ int main(int argc, char **argv) {
printf("\033[0m\n");
}
for (; j < fetch.logo_size; j++)
for (; j < fetch.logo_size - 1; j++)
if (!l_flag)
printf("%s\n", fetch.logo[j]);

32
themes/default.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef _CONFIG_H
#define _CONFIG_H
#include "fetch.h"
#include "structs.h"
/* 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"
#ifdef _MAIN_C
#define ON_ERROR_STR "none"
PARAMETR CONFIG[] = {
{PrintOs, {.str0=" os ", .str1=NULL}},
{GetKernel, {.str0=" kr ", .str1=NULL}},
{GetUser, {.str0=" usr ", .str1=NULL}},
{GetUptime, {.str0=" upt ", .str1=NULL}},
{GetArch, {.str0=" arch ", .str1=NULL}},
{GetShell, {.str0="shell ", .str1=NULL}},
{GetPkg, {.str0=" pkgs ", .str1=NULL}},
{GetMem, {.str0=" mem ", .str1=NULL}},
{GetModel, {.str0="model ", .str1=NULL}},
{GetHostname, {.str0=" host ", .str1=NULL}},
{GetAVG, {.str0=" AVG ", .str1=NULL}},
{Blank, {.str0=" ", .str1=NULL}},
{Execute, {.str0=" Id's ", .str1=NULL, .str2="id -gn"}},
{Blank, {.str0=COLORS, .str1=NULL}}
};
#endif
#endif