aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnser <rostgans@tutamail.com>2026-08-11 13:11:39 +0200
committerAnser <rostgans@tutamail.com>2026-08-11 20:04:21 +0200
commit729746e50ebc8e4eb4c98f7556a241aec111e07d (patch)
treee33e627474fdba4c625bb72f9848b1f067303aff
parenteb6f986361713d6ce47c6d4572bb24d9f6207ddf (diff)
some more rework in readme.md and src file structure
-rw-r--r--Makefile6
-rw-r--r--README.md23
-rwxr-xr-xcfetchbin0 -> 17160 bytes
-rw-r--r--include/cfetch.h4
-rw-r--r--src/ascii.c (renamed from src/logo.c)2
-rw-r--r--src/cfetch.c2
-rw-r--r--src/cpu.c44
-rw-r--r--src/memory.c26
-rw-r--r--src/os.c18
-rw-r--r--src/sysinfo.c85
10 files changed, 111 insertions, 99 deletions
diff --git a/Makefile b/Makefile
index 740c92e..b6df30d 100644
--- a/Makefile
+++ b/Makefile
@@ -13,10 +13,8 @@ PREFIX ?= /usr/local
TARGET = cfetch
SRC = src/cfetch.c \
- src/os.c \
- src/memory.c \
- src/cpu.c \
- src/logo.c \
+ src/sysinfo.c \
+ src/ascii.c \
src/utils.c
.PHONY: all clean install uninstall debug
diff --git a/README.md b/README.md
index 4325487..ae4e17f 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,39 @@
-# Idee
+# Idea
- fastfetch / commiefetch in C
- with emphasis on commiefetch, i want communism stuff but in C !
# Install
- git clone this project
+ - `git clone https://codeberg.org/Anser/cfetch.git`
- `make` for local install (e.g. binary will be placed inside the project folder)
-- `sudo/doas make` for systemwide install
+- `sudo/doas make install` for systemwide install (requieres root privileges)
- `make clean` for local removal
- `sudo/doas make uninstall` for systemwide uninstallation
+## install localy
+```bash
+git clone https://codeberg.org/Anser/cfetch.git && \
+cd cfetch && \
+make
+```
+
+## install global
+```bash
+git clone https://codeberg.org/Anser/cfetch.git && \
+cd cfetch && \
+sudo make install
+```
+
# Features - not much !
| Feature | Linux |
|---------|-------|
| OS Info | OK |
-| Kernel | X |
+| Kernel | todo |
| CPU | OK |
| Memory | OK |
+| username | todo |
+| ascii_art | todo |
# Reference
diff --git a/cfetch b/cfetch
new file mode 100755
index 0000000..15b12c9
--- /dev/null
+++ b/cfetch
Binary files differ
diff --git a/include/cfetch.h b/include/cfetch.h
index 57c8781..d8a6f92 100644
--- a/include/cfetch.h
+++ b/include/cfetch.h
@@ -28,6 +28,7 @@ typedef struct distro_mapping_t
const char *ascii_file;
} distro_mapping_t;
+/* System info functions */
void print_ascii_art(system_info_t *info, int art);
void get_cpu(system_info_t *info);
@@ -36,9 +37,8 @@ void get_os(system_info_t *info);
/* Util functions */
+
char *string_format(char *string);
char *concat(const char *str1, const char *str2);
-
-
#endif /* CFETCH_H */
diff --git a/src/logo.c b/src/ascii.c
index 641de75..b4df816 100644
--- a/src/logo.c
+++ b/src/ascii.c
@@ -34,7 +34,7 @@ const char* get_ascii_name(const distro_mapping_t *d_map, int art)
void print_ascii_art(system_info_t *info, int art)
{
// get ascii name
- const char* name = get_ascii_name(distro_mappings[], art);
+ const char* name = get_ascii_name(distro_mappings, art);
char* path = concat("../ascii/", name);
if (path == NULL)
diff --git a/src/cfetch.c b/src/cfetch.c
index 3977bb1..92157d4 100644
--- a/src/cfetch.c
+++ b/src/cfetch.c
@@ -24,7 +24,7 @@ int main(void) {
get_os(&info);
get_memory(&info);
get_cpu(&info);
- print_ascii_art(&info, art_logo);
+ //print_ascii_art(&info, art_logo);
return 0;
}
diff --git a/src/cpu.c b/src/cpu.c
deleted file mode 100644
index c45cd9e..0000000
--- a/src/cpu.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "../include/cfetch.h"
-
-void get_cpu(system_info_t *info) {
- FILE* file = fopen("/proc/cpuinfo", "r");
-
- //check file existence
- if (!file) {
- perror("/proc/cpuinfo not found");
- return;
- }
-
- char line[256];
- char *model_name = NULL;
-
- //read per line
- while (fgets(line, sizeof(line), file)) {
- char* p = strstr(line, "model name");
-
- if (p != NULL) {
- model_name = strchr(p, ':') + 1; //skip :
- break;
- }
- }
-
- if (model_name != NULL) {
- char *string = string_format(model_name);
-
- if (string == NULL) {
- printf("CPU: Error string not found.\n");
- free(string);
- model_name = NULL;
- } else {
- printf("CPU: %s\n", string);
- free(string);
- model_name = NULL;
- }
-
- } else {
- printf("CPU: Error model_name not found.\n");
- }
-
- fclose(file);
- return;
-}
diff --git a/src/memory.c b/src/memory.c
deleted file mode 100644
index 9e880d2..0000000
--- a/src/memory.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "../include/cfetch.h"
-
-void get_memory(system_info_t *info) {
- FILE *file = fopen("/proc/meminfo", "r");
-
- if (!file) {
- perror("Error fopen meminfo");
- return;
- }
-
- char line[256];
- long total = 0;
- long available = 0;
-
- // read per line
- while (fgets(line, sizeof(line), file)) {
- if (sscanf(line, "MemTotal: %ld kB", &total) == 1) continue;
- if (sscanf(line, "MemAvailable: %ld kB", &available) == 1) continue;
- }
-
- fclose(file);
-
- printf("Memory: %.2f GB / %.2f GB\n", (total - available) / (1024.0 * 1024.0), total / (1024.0 * 1024.0));
-
- return;
-}
diff --git a/src/os.c b/src/os.c
deleted file mode 100644
index fd5b7ae..0000000
--- a/src/os.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "../include/cfetch.h"
-
-#include <sys/utsname.h>
-
-void get_os(system_info_t *info) {
-#ifdef __linux__
- struct utsname u;
-
- if (uname(&u) == 0) {
- size_t length = printf("OS: %s %s %s %s\n", u.sysname, u.release, u.version, u.machine);
- printf("line length: %ld\n", length);
- } else {
- perror("Error while accessing uname");
- return;
- }
-#endif
- return;
-}
diff --git a/src/sysinfo.c b/src/sysinfo.c
new file mode 100644
index 0000000..0a91eca
--- /dev/null
+++ b/src/sysinfo.c
@@ -0,0 +1,85 @@
+#include "../include/cfetch.h"
+#include <sys/utsname.h>
+
+void get_os(system_info_t *info) {
+#ifdef __linux__
+ struct utsname u;
+
+ if (uname(&u) == 0) {
+ size_t length = printf("OS: %s %s %s %s\n", u.sysname, u.release, u.version, u.machine);
+ printf("line length: %ld\n", length);
+ } else {
+ perror("Error while accessing uname");
+ return;
+ }
+#endif
+ return;
+}
+
+void get_cpu(system_info_t *info) {
+ FILE* file = fopen("/proc/cpuinfo", "r");
+
+ //check file existence
+ if (!file) {
+ perror("/proc/cpuinfo not found");
+ return;
+ }
+
+ char line[256];
+ char *model_name = NULL;
+
+ //read per line
+ while (fgets(line, sizeof(line), file)) {
+ char* p = strstr(line, "model name");
+
+ if (p != NULL) {
+ model_name = strchr(p, ':') + 1; //skip :
+ break;
+ }
+ }
+
+ if (model_name != NULL) {
+ char *string = string_format(model_name);
+
+ if (string == NULL) {
+ printf("CPU: Error string not found.\n");
+ free(string);
+ model_name = NULL;
+ } else {
+ printf("CPU: %s\n", string);
+ free(string);
+ model_name = NULL;
+ }
+
+ } else {
+ printf("CPU: Error model_name not found.\n");
+ }
+
+ fclose(file);
+ return;
+}
+
+void get_memory(system_info_t *info) {
+ FILE *file = fopen("/proc/meminfo", "r");
+
+ if (!file) {
+ perror("Error fopen meminfo");
+ return;
+ }
+
+ char line[256];
+ long total = 0;
+ long available = 0;
+
+ // read per line
+ while (fgets(line, sizeof(line), file)) {
+ if (sscanf(line, "MemTotal: %ld kB", &total) == 1) continue;
+ if (sscanf(line, "MemAvailable: %ld kB", &available) == 1) continue;
+ }
+
+ fclose(file);
+
+ printf("Memory: %.2f GB / %.2f GB\n", (total - available) / (1024.0 * 1024.0), total / (1024.0 * 1024.0));
+
+ return;
+}