:)
This commit is contained in:
parent
7f7ca8c507
commit
22c4e8cdb0
8
Makefile
8
Makefile
@ -1,8 +0,0 @@
|
|||||||
CFLAGS?=-s -Os -pedantic -Wall -Wextra
|
|
||||||
CC?=cc
|
|
||||||
|
|
||||||
all:
|
|
||||||
$(CC) src/*.c -Iinclude -I. $(CFLAGS) -okfetch
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm obj/* bin/*
|
|
8
build.sh
Executable file
8
build.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
CC=cc
|
||||||
|
FLAGS="-Os -s"
|
||||||
|
|
||||||
|
$CC -Iinclude -I. src/main.c -c -o main.o
|
||||||
|
$CC -Iinclude -I. src/fetch.c -c -o fetch.o
|
||||||
|
$CC $FLAGS main.o fetch.o -o kfetch
|
||||||
|
rm main.o fetch.o
|
18
config.h
18
config.h
@ -14,15 +14,15 @@ typedef struct {
|
|||||||
|
|
||||||
#ifdef _MAIN_H
|
#ifdef _MAIN_H
|
||||||
PARAMETR CONFIG[] = {
|
PARAMETR CONFIG[] = {
|
||||||
{" --- ", GetUser},
|
{" ", PrintOs},
|
||||||
{"\033[31m ", PrintOs},
|
{" ", GetKernel},
|
||||||
{"\033[32m ", GetKernel},
|
{" ", GetUser},
|
||||||
{"\033[33m ", GetUser},
|
{" ", GetUptime},
|
||||||
{"\033[34m ", GetUptime},
|
{" ", GetArch},
|
||||||
{"\033[35m ", GetArch},
|
{" ", GetShell},
|
||||||
{"\033[36m ", GetShell},
|
{" ", GetPkg},
|
||||||
{"\033[37m ", GetPkg},
|
{" ", GetMem},
|
||||||
{"\033[38m ", GetMem},
|
{" ", GetModel},
|
||||||
{" ", Blank},
|
{" ", Blank},
|
||||||
{" ", PrintColors}
|
{" ", PrintColors}
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define OS_SIZE 128
|
#define OS_SIZE 128
|
||||||
|
#define MODEL_BUFF_SIZE 512
|
||||||
|
static const char *MODELS[] = {
|
||||||
|
"/sys/devices/virtual/dmi/id/product_name",
|
||||||
|
"/sys/devices/virtual/dmi/id/product_version",
|
||||||
|
"/sys/firmware/devicetree/base/model"
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char os_name[OS_SIZE + 1];
|
char os_name[OS_SIZE + 1];
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
@ -37,5 +44,6 @@ int GetArch(const char *title, const FETCH fetch);
|
|||||||
int GetShell(const char *title, const FETCH fetch);
|
int GetShell(const char *title, const FETCH fetch);
|
||||||
int GetPkg(const char *title, const FETCH fetch);
|
int GetPkg(const char *title, const FETCH fetch);
|
||||||
int GetMem(const char *title, const FETCH fetch);
|
int GetMem(const char *title, const FETCH fetch);
|
||||||
|
int GetModel(const char *title, const FETCH fetch);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
20
src/fetch.c
20
src/fetch.c
@ -201,3 +201,23 @@ int GetMem(const char *title, const FETCH fetch) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetModel(const char *title, const FETCH fetch) {
|
||||||
|
FILE *fp = NULL;
|
||||||
|
for (size_t i = 0; i < sizeof(MODELS) / sizeof(char *); i++) {
|
||||||
|
fp = fopen(MODELS[i], "r");
|
||||||
|
if (fp != NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
char model_buffer[MODEL_BUFF_SIZE + 1];
|
||||||
|
char *ptr = fgets(model_buffer, sizeof(model_buffer), fp);
|
||||||
|
if (ptr != NULL)
|
||||||
|
printf("%s%s%s%s", fetch.color, title, fetch.font_color, model_buffer);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user