forked from nakidai/mycfetch
1
0
Fork 0
master
Plaza521 2023-06-10 17:56:49 +03:00
parent 07f1b79181
commit 095c752d99
5 changed files with 81 additions and 0 deletions

1
build.sh Normal file
View File

@ -0,0 +1 @@
gcc main.c info.c -o mycoolneofetch

48
info.c Normal file
View File

@ -0,0 +1,48 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
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;
}

3
info.h Normal file
View File

@ -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

11
main.c Normal file
View File

@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "info.h"
int main(int argc, char **argv)
{
#include "order.c"
return 0;
}

18
order.c Normal file
View File

@ -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());