diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..c8112de --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +gcc main.c info.c -o mycoolneofetch \ No newline at end of file diff --git a/info.c b/info.c new file mode 100644 index 0000000..cf8a571 --- /dev/null +++ b/info.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include + +char *GetKernelVer(void) +{ + FILE *ptr; + char *uptime = malloc(50 * sizeof(char)); + for (int i = 0; i < 50; ++i) + uptime[i] = 0; + ptr = popen("/bin/uname -r", "r"); + if (ptr == NULL) + return "idk"; + fgets(uptime, 49, ptr); + pclose(ptr); + int i = 0; + for (i = 0; uptime[i] != 0; ++i); + uptime[i-1] = 0; + return uptime; +} + +char *GetCurrentUser(void) +{ + char *user = getenv("USER"); + char *host = malloc(25 * sizeof(char)); + char *out = malloc(50 * sizeof(char)); + gethostname(host, 25); + sprintf(out, "%s@%s", user, host); + return out; +} + +char *GetUptime(void) +{ + FILE *ptr; + char *uptime = malloc(50 * sizeof(char)); + for (int i = 0; i < 50; ++i) + uptime[i] = 0; + ptr = popen("/bin/uptime -p", "r"); + if (ptr == NULL) + return "idk"; + fgets(uptime, 49, ptr); + pclose(ptr); + int i = 0; + for (i = 0; uptime[i] != 0; ++i); + uptime[i-1] = 0; + return uptime+3; +} diff --git a/info.h b/info.h new file mode 100644 index 0000000..61a10bf --- /dev/null +++ b/info.h @@ -0,0 +1,3 @@ +char *GetKernelVer(void); // takes kernel version from /proc/version +char *GetCurrentUser(void); // user@pc +char *GetUptime(void); // takes uptime from uptime -p \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..52be321 --- /dev/null +++ b/main.c @@ -0,0 +1,11 @@ +#include +#include +#include + +#include "info.h" + +int main(int argc, char **argv) +{ +#include "order.c" + return 0; +} diff --git a/order.c b/order.c new file mode 100644 index 0000000..0fd7049 --- /dev/null +++ b/order.c @@ -0,0 +1,18 @@ +/* + * Printf needed info + * Don't include here any libraries +*/ + +// Gentoo + +// printf(" /‾\\  %s\n", GetCurrentUser()); +// printf("( o \\\n"); +// printf("/ /  %s\n", GetKernelVer()); +// printf("\\__/  %s\n", GetUptime()); + +// Arch + +printf(" /\\  %s\n", GetCurrentUser()); +printf(" /\\ \\\n"); +printf(" / \\  %s\n", GetKernelVer()); +printf("/__/\\__\\  %s\n", GetUptime());