forked from nakidai/mycfetch
Add code
parent
07f1b79181
commit
095c752d99
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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());
|
Loading…
Reference in New Issue