forked from nakidai/mycfetch
Add *argument*
parent
c300ebeadf
commit
806f176ab0
14
README.md
14
README.md
|
@ -1,3 +1,15 @@
|
||||||
# mycfetch
|
# mycfetch
|
||||||
|
|
||||||
Simle neofetch.
|
Simple neofetch.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
--
|
||||||
|
Use argument to select art. If not argument provided, mycfetch uses first entry in arts list.
|
||||||
|
For your convenience, you can set alias for needed art.
|
||||||
|
|
||||||
|
List of arts
|
||||||
|
--
|
||||||
|
- `cat`
|
||||||
|
- `freebsd`
|
||||||
|
- `gentoo`
|
||||||
|
- `arch`
|
||||||
|
|
57
config.h
57
config.h
|
@ -1,29 +1,44 @@
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
const int max_username_length = 128;
|
const int max_username_length = 128;
|
||||||
const int max_hostname_length = 128;
|
const int max_hostname_length = 128;
|
||||||
const int max_uptime_length = 40;
|
const int max_uptime_length = 40;
|
||||||
|
|
||||||
char *art[] = {
|
struct art_entry arts[] = {
|
||||||
// FreeBSD
|
{
|
||||||
|
"cat",
|
||||||
|
{
|
||||||
|
" ╱|、 ",
|
||||||
|
"(˚ˎ。7 ",
|
||||||
|
"| 、˜〵 ",
|
||||||
|
"じしˍ,)ノ"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"freebsd",
|
||||||
|
{
|
||||||
"\033[31m_ _\033[0m",
|
"\033[31m_ _\033[0m",
|
||||||
"\033[31m\\‾‾‾‾/\033[0m",
|
"\033[31m\\‾‾‾‾/\033[0m",
|
||||||
"\033[31m|^ww^|\033[0m",
|
"\033[31m|^vv^|\033[0m",
|
||||||
"\033[31m\\____/\033[0m"
|
"\033[31m\\____/\033[0m"
|
||||||
|
}
|
||||||
// Gentoo
|
},
|
||||||
// "\x1B[38;5;135m /‾\\",
|
{
|
||||||
// "\x1B[38;5;135m( \x1B[38;5;183mo \x1B[38;5;135m\\",
|
"gentoo",
|
||||||
// "\x1B[38;5;135m/ /",
|
{
|
||||||
// "\x1B[38;5;135m\\__/"
|
" /‾\\ ",
|
||||||
|
"( o \\",
|
||||||
// Arch
|
"/ /",
|
||||||
// " /\\ ",
|
"\\__/ "
|
||||||
// " /\\ \\ ",
|
}
|
||||||
// " / \\ ",
|
},
|
||||||
// "/__/\\__\\"
|
{
|
||||||
|
"arch",
|
||||||
// Just cute cat
|
{
|
||||||
// " ╱|、 ",
|
" /\\ ",
|
||||||
// "(˚ˎ。7 ",
|
" /\\ \\ ",
|
||||||
// " |、˜〵 ",
|
" / \\ ",
|
||||||
// "じしˍ,)ノ"
|
"/__/\\__\\"
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef __DEFS_H__
|
||||||
|
#define __DEFS_H__
|
||||||
|
|
||||||
|
struct art_entry
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *art[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __DEFS_H__ */
|
30
main.c
30
main.c
|
@ -1,9 +1,22 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
|
void die(int code, char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
exit(code);
|
||||||
|
}
|
||||||
|
|
||||||
void getuptime(char *buffer, int max_length)
|
void getuptime(char *buffer, int max_length)
|
||||||
{
|
{
|
||||||
|
@ -26,21 +39,34 @@ void getuptime(char *buffer, int max_length)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
if (argc > 2) die(1, "usage: %s [artname]\n", argv[0]);
|
||||||
|
|
||||||
struct utsname uname_buf;
|
struct utsname uname_buf;
|
||||||
struct timespec uptime_buf;
|
|
||||||
char hostname[max_hostname_length];
|
char hostname[max_hostname_length];
|
||||||
char username[max_username_length];
|
char username[max_username_length];
|
||||||
char uptime[max_uptime_length];
|
char uptime[max_uptime_length];
|
||||||
|
|
||||||
|
int i;
|
||||||
|
char **art = NULL;
|
||||||
|
|
||||||
gethostname(hostname, max_hostname_length);
|
gethostname(hostname, max_hostname_length);
|
||||||
getlogin_r(username, max_username_length);
|
getlogin_r(username, max_username_length);
|
||||||
getuptime(uptime, max_uptime_length);
|
getuptime(uptime, max_uptime_length);
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
for (i = 0; i < sizeof(arts)/sizeof(struct art_entry); ++i)
|
||||||
|
if (!strcmp(arts[i].name, argv[1])) { art = arts[i].art; break; }
|
||||||
|
if (!art) die(1, "Art %s not found\n", argv[1]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
art = arts[0].art;
|
||||||
|
}
|
||||||
|
|
||||||
uname(&uname_buf);
|
uname(&uname_buf);
|
||||||
printf("%s %s@%s\n", art[0], username, hostname);
|
printf("%s %s@%s\n", art[0], username, hostname);
|
||||||
printf("%s --\n", art[1]);
|
printf("%s --\n", art[1]);
|
||||||
printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release);
|
printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release);
|
||||||
printf("%s %s\n", art[3], uptime);
|
printf("%s %s\n", art[3], uptime);
|
||||||
// #include "order.c"
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue