add themes
This commit is contained in:
parent
7ab3e8ef0c
commit
a3a17c2b8b
@ -1 +1,4 @@
|
||||
![kfetch](/img/kfetch.jpg)
|
||||
themes/ - contain various versions of config.h
|
||||
exp:
|
||||
cp themes/tree.h config.h
|
||||
|
6
build.sh
6
build.sh
@ -2,7 +2,7 @@
|
||||
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
|
||||
$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
|
||||
|
14
config.h
14
config.h
@ -9,9 +9,14 @@ typedef struct {
|
||||
} PARAMETR;
|
||||
|
||||
/* 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 */
|
||||
#define PRINT_USED_AND_TOTAL_MEM
|
||||
|
||||
#ifdef _MAIN_H
|
||||
PARAMETR CONFIG[] = {
|
||||
{" os ", PrintOs},
|
||||
@ -19,13 +24,14 @@ PARAMETR CONFIG[] = {
|
||||
{" usr ", GetUser},
|
||||
{" upt ", GetUptime},
|
||||
{" arch ", GetArch},
|
||||
{" shl ", GetShell},
|
||||
{" pkg ", GetPkg},
|
||||
{"shell ", GetShell},
|
||||
{" pkgs ", GetPkg},
|
||||
{" mem ", GetMem},
|
||||
{" mod ", GetModel},
|
||||
{"model ", GetModel},
|
||||
{" host ", GetHostname},
|
||||
{" lAVG ", GetAVG},
|
||||
{" ", Blank},
|
||||
{" ", PrintColors}
|
||||
{COLORS, Blank}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef _FUNCS_H
|
||||
#define _FUNCS_H
|
||||
#ifndef _FETCH_H
|
||||
#define _FETCH_H
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
@ -36,7 +36,6 @@ int GetOs(char *os_name, size_t len);
|
||||
void GetArt(FETCH *fetch, int flag);
|
||||
int GetKernel(const char *title, const FETCH fetch);
|
||||
int PrintOs(const char *title, const FETCH fetch);
|
||||
int PrintColors(const char *title, const FETCH fetch);
|
||||
int Blank(const char *title, const FETCH fetch);
|
||||
int GetUser(const char *title, const FETCH fetch);
|
||||
int GetUptime(const char *title, const FETCH fetch);
|
||||
@ -46,5 +45,6 @@ int GetPkg(const char *title, const FETCH fetch);
|
||||
int GetMem(const char *title, const FETCH fetch);
|
||||
int GetModel(const char *title, const FETCH fetch);
|
||||
int GetHostname(const char *title, const FETCH fetch);
|
||||
int GetAVG(const char *title, const FETCH fetch);
|
||||
|
||||
#endif
|
||||
|
@ -102,3 +102,4 @@ char *Unknow[] = {
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
43
src/fetch.c
43
src/fetch.c
@ -103,15 +103,6 @@ int PrintOs(const char *title, const FETCH fetch) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PrintColors(const char *title, const FETCH fetch) {
|
||||
printf("%s%s%s", fetch.color, title, fetch.font_color);
|
||||
|
||||
for (int i = 1; i < 7; i++)
|
||||
printf("\033[1;3%dm%s\033[0m ", i, PC_CHAR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Blank(const char *title, const FETCH fetch) {
|
||||
printf("%s%s%s", fetch.color, title, fetch.font_color);
|
||||
return 0;
|
||||
@ -195,14 +186,22 @@ int GetMem(const char *title, const FETCH fetch) {
|
||||
if (fp == NULL)
|
||||
return 1;
|
||||
|
||||
off_t unused = 0, total = 0, available = 0;
|
||||
if (fscanf(fp, "MemTotal: %lu kB\nMemFree: %lu kB\nMemAvailable: %lu kB", &total, &unused, &available) < 0)
|
||||
off_t free = 0, total = 0;
|
||||
if (fscanf(fp, "MemTotal: %lu kB\nMemFree: %lu kB", &total, &free) < 0)
|
||||
return 1;
|
||||
|
||||
UNUSED(unused);
|
||||
printf("%s%s%s%lumb / %lumb", fetch.color, title, fetch.font_color, (uintmax_t)(total - available) / 1024, (uintmax_t)total / 1024);
|
||||
fclose(fp);
|
||||
#ifdef PRINT_USED_AND_TOTAL_MEM
|
||||
printf("%s%s%s%lumb / %lumb", fetch.color, title, fetch.font_color, (uintmax_t)(total - free) / 1024, (uintmax_t)total / 1024);
|
||||
|
||||
#elif PRINT_TOTALMEM
|
||||
printf("%s%s%s%lumb", fetch.color, title, fetch.font_color, (uintmax_t)total / 1024);
|
||||
|
||||
#else
|
||||
printf("%s%s%s%lumb", fetch.color, title, fetch.font_color, (uintmax_t)(total - free) / 1024);
|
||||
|
||||
#endif
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -241,3 +240,19 @@ int GetHostname(const char *title, const FETCH fetch) {
|
||||
printf("%s%s%s%s", fetch.color, title, fetch.font_color, hostname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetAVG(const char *title, const FETCH fetch) {
|
||||
#ifndef __ANDROID__
|
||||
double avg[3] = {0, 0, 0};
|
||||
|
||||
if (getloadavg(avg, sizeof(avg) / sizeof(avg[0])) < 0)
|
||||
return 1;
|
||||
|
||||
printf("%s%s%s%.2f %.2f %.2f", fetch.color, title, fetch.font_color, avg[0], avg[1], avg[2]);
|
||||
return 0;
|
||||
|
||||
#else
|
||||
return 1;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#define _MAIN_H
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <string.h>
|
||||
#include "fetch.h"
|
||||
#include "config.h"
|
||||
|
||||
|
0
themes/.gitignore
vendored
Normal file
0
themes/.gitignore
vendored
Normal file
39
themes/default.h
Normal file
39
themes/default.h
Normal file
@ -0,0 +1,39 @@
|
||||
#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[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 */
|
||||
#define PRINT_USED_AND_TOTAL_MEM
|
||||
|
||||
#ifdef _MAIN_H
|
||||
PARAMETR CONFIG[] = {
|
||||
{" os ", PrintOs},
|
||||
{" kr ", GetKernel},
|
||||
{" usr ", GetUser},
|
||||
{" upt ", GetUptime},
|
||||
{" arch ", GetArch},
|
||||
{"shell ", GetShell},
|
||||
{" pkgs ", GetPkg},
|
||||
{" mem ", GetMem},
|
||||
{"model ", GetModel},
|
||||
{" host ", GetHostname},
|
||||
{" lAVG ", GetAVG},
|
||||
{" ", Blank},
|
||||
{COLORS, Blank}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
32
themes/fira.h
Normal file
32
themes/fira.h
Normal file
@ -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 PC_CHAR "<>"
|
||||
|
||||
/* #define PRINT_TOTAL_MEM */
|
||||
/* #define PRINT_USER_MEM */
|
||||
#define PRINT_USED_AND_TOTAL_MEM
|
||||
|
||||
#ifdef _MAIN_H
|
||||
PARAMETR CONFIG[] = {
|
||||
{" ", PrintOs},
|
||||
{" ", GetKernel},
|
||||
{" ", GetUptime},
|
||||
{" ", GetPkg},
|
||||
{" ", Blank},
|
||||
{COLORS, Blank}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
41
themes/tree.h
Normal file
41
themes/tree.h
Normal file
@ -0,0 +1,41 @@
|
||||
#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[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 */
|
||||
#define PRINT_USED_AND_TOTAL_MEM
|
||||
|
||||
#ifdef _MAIN_H
|
||||
PARAMETR CONFIG[] = {
|
||||
{" pc: ", Blank},
|
||||
{" - mem ", GetMem},
|
||||
{" - kr ", GetKernel},
|
||||
{" - ar ", GetArch},
|
||||
{" - mod ", GetModel},
|
||||
{" - ht ", GetHostname},
|
||||
{" ", Blank},
|
||||
{" - other: ", Blank},
|
||||
{" - os ", PrintOs},
|
||||
{" - shl ", GetShell},
|
||||
{" - pkg ", GetPkg},
|
||||
{" - up ", GetUptime},
|
||||
{" - avg ", GetAVG},
|
||||
{" ", Blank},
|
||||
{COLORS, Blank}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user