diff --git a/Makefile b/Makefile index a264e71..c2e3633 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ CC := cc CFLAGS := -all: mycfetch +all: hiscfetch mycfetch: main.c config.h - $(CC) main.c -o mycfetch $(CFLAGS) + $(CC) main.c -o hiscfetch $(CFLAGS) install: mycfetch - cp mycfetch /usr/bin/mycfetch + cp hiscfetch /usr/bin/hiscfetch clean: - rm mycfetch + rm hiscfetch .PHONY: all install clean diff --git a/config.h b/config.h index 6b5e7c4..6432237 100644 --- a/config.h +++ b/config.h @@ -1,101 +1,148 @@ +#include "defs.h" + const int max_username_length = 128; const int max_hostname_length = 128; const int max_uptime_length = 40; - -char *art[] = { -// FreeBSD -// "\033[31m_ _\033[0m", -// "\033[31m\\‾‾‾‾/\033[0m", -// "\033[31m|^ww^|\033[0m", -// "\033[31m\\____/\033[0m" - -// Gentoo -// "\x1B[38;5;135m /‾\\", -// "\x1B[38;5;135m( \x1B[38;5;183mo \x1B[38;5;135m\\", -// "\x1B[38;5;135m/ /", -// "\x1B[38;5;135m\\__/" - -// Arch -// " /\\ ", -// " /\\ \\ ", -// " / \\ ", -// "/__/\\__\\" - -// Just cute cat -// " ╱|、 ", -// "(˚ˎ。7 ", -// " |、˜〵 ", -// "じしˍ,)ノ" - -// Ubuntu -// "\033[31m /‾‾‾‾‾\\ \033[0m", -// "\033[31m| o---o |\033[0m", -// "\033[31m| \\o/ |\033[0m", -// "\033[31m \\_____/ \033[0m" - -// Mint (shitty) -// "\e[0;32m| ‾T‾T‾T‾\\ \033[0m", -// "\e[0;32m| | | | | \033[0m", -// "\e[0;32m| | | | | \033[0m", -// "\e[0;32mL________J \033[0m" - -// Debian -// "\e[0;31m I‾‾‾‾‾\\ \033[0m", -// "\e[0;31m | I‾‾‾ | \033[0m", -// "\e[0;31m \\ L___/ \033[0m", -// "\e[0;31m \\ \033[0m" - -// Manjaro -// "\e[0;32mMM MMMM \033[0m", -// "\e[0;32mMM MMMM \033[0m", -// "\e[0;32mMM M \033[0m", -// "\e[0;32mMM M M \033[0m" - -// Slackware (quite shitty) -// "\e[0;34m _____ \033[0m", -// "\e[0;34m L___ \033[0m", -// "\e[0;34m| ____J \033[0m", -// "\e[0;34mL_______ \033[0m" - -// Triangle Linux -// "\e[0;36m /\\ \033[0m", -// "\e[0;36m /\ \\ \033[0m", -// "\e[0;36m/ \ \\\033[0m", -// "\e[0;36m‾‾‾‾‾‾\033[0m" - -// Distro not found -" /‾‾‾‾‾\\", -" |", -" /‾‾ ", -" 0 " -// Fedora -// "\e[0;34m /‾‾‾‾‾\\\033[0m", -// "\e[0;34m | |‾‾‾ |\033[0m", -// "\e[0;34m | J‾‾‾ |\033[0m", -// "\e[0;34m L_____/ \033[0m" - -// elementaryOS -// " /‾‾‾‾‾‾\\", -// "| /‾‾‾‾\\ |", -// "|/|‾‾‾‾‾ |", -// " \\🮀🮀🮀🮀__/" - -// Kali Linux (omg dont hack me pls) -// "\e[0;34m \\ \\ \033[0m", -// "\e[0;34m --/‾‾‾‾\\\033[0m", -// "\e[0;34m \\ o\033[0m", -// "\e[0;34m \\ \033[0m", - -// Artix (shitty) -// "\e[0;34m /\\ \033[0m", -// "\e[0;34m /\\/\\ \033[0m", -// "\e[0;34m / /\\ \\ \033[0m", -// "\e[0;34m/_//\\__\\\033[0m" - -// da fuckin stickman -// " 0 ", -// " /|\\ ", -// " | ", -// " / \\ " +struct art_entry arts[] = { + { + "cat", + { + " ╱|、 ", + "(˚ˎ。7 ", + "| 、˜〵 ", + "じしˍ,)ノ" + } + }, + { + "freebsd", + { + "\033[31m_ _\033[0m", + "\033[31m\\‾‾‾‾/\033[0m", + "\033[31m|^vv^|\033[0m", + "\033[31m\\____/\033[0m" + } + }, + { + "gentoo", + { + " /‾\\ ", + "( o \\", + "/ /", + "\\__/ " + } + }, + { + "arch", + { + " /\\ ", + " /\\ \\ ", + " / \\ ", + "/__/\\__\\" + } + }, + { "ubuntu", + { + "\033[31m /‾‾‾‾‾\\ \033[0m", + "\033[31m| o---o |\033[0m", + "\033[31m| \\o/ |\033[0m", + "\033[31m \\_____/ \033[0m" + } + }, + { "mint", + { + "\e[0;32m| ‾T‾T‾T‾\\ \033[0m", + "\e[0;32m| | | | | \033[0m", + "\e[0;32m| | | | | \033[0m", + "\e[0;32mL________J \033[0m" + } + }, + { "debian", + { + "\e[0;31m I‾‾‾‾‾\\ \033[0m", + "\e[0;31m | I‾‾‾ | \033[0m", + "\e[0;31m \\ L___/ \033[0m", + "\e[0;31m \\ \033[0m" + } + }, + { "manjaro", + { + "\e[0;32mMM MMMM \033[0m", + "\e[0;32mMM MMMM \033[0m", + "\e[0;32mMM M \033[0m", + "\e[0;32mMM M M \033[0m" + } + }, + { "slackware", + { + "\e[0;34m _____ \033[0m", + "\e[0;34m L___ \033[0m", + "\e[0;34m| ____J \033[0m", + "\e[0;34mL_______ \033[0m" + } + }, + { "triangle", + { + "\e[0;36m /\\ \033[0m", + "\e[0;36m /\\ \\ \033[0m", + "\e[0;36m/ \\ \\\033[0m", + "\e[0;36m‾‾‾‾‾‾\033[0m" + } + }, + { "?", + { + " /‾‾‾‾\\ ", + " | ", + " /‾ ", + " 0 " + } + }, + { "fedora", + { + "\e[0;34m /‾‾‾‾‾\\\033[0m", + "\e[0;34m | |‾‾‾ |\033[0m", + "\e[0;34m | J‾‾‾ |\033[0m", + "\e[0;34m L_____/ \033[0m" + } + }, + { "elementary", + { + " /‾‾‾‾‾‾\\", + "| /‾‾‾‾\\ |", + "|/|‾‾‾‾‾ |", + " \\🮀🮀🮀🮀__/" + } + }, + { "kali", + { + "\e[0;34m \\ \\ \033[0m", + "\e[0;34m --/‾‾‾‾\\\033[0m", + "\e[0;34m \\ o\033[0m", + "\e[0;34m \\ \033[0m", + } + }, + { "artix", + { + "\e[0;34m /\\ \033[0m", + "\e[0;34m /\\/\\ \033[0m", + "\e[0;34m / /\\ \\ \033[0m", + "\e[0;34m/_//\\__\\\033[0m" + } + }, + { "dafuckinstikman", + { + " 0 ", + " /|\\ ", + " | ", + " / \\ " + } + }, + { "templeos", + { + "\e[0;34m|‾‾‾‾/‾‾‾|\e[0;37m", + "\e[0;34m|\e[0;33mtempleOS\e[0;34m|\e[0;37m", + "\e[0;34m| -/- |\e[0;37m", + "\e[0;34mL_/______J\e[0;37m" + } + } }; diff --git a/defs.h b/defs.h new file mode 100644 index 0000000..cf22476 --- /dev/null +++ b/defs.h @@ -0,0 +1,10 @@ +#ifndef __DEFS_H__ +#define __DEFS_H__ + +struct art_entry +{ + char *name; + char *art[4]; +}; + +#endif /* __DEFS_H__ */ diff --git a/main.c b/main.c index f616239..954809e 100644 --- a/main.c +++ b/main.c @@ -1,9 +1,22 @@ #include +#include #include #include #include +#include +#include #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) { @@ -26,21 +39,34 @@ void getuptime(char *buffer, int max_length) int main(int argc, char **argv) { + if (argc > 2) die(1, "usage: %s [artname]\n", argv[0]); + struct utsname uname_buf; - struct timespec uptime_buf; char hostname[max_hostname_length]; char username[max_username_length]; char uptime[max_uptime_length]; + int i; + char **art = NULL; + gethostname(hostname, max_hostname_length); getlogin_r(username, max_username_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); printf("%s %s@%s\n", art[0], username, hostname); printf("%s ----------\n", art[1]); printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release); printf("%s %s\n", art[3], uptime); - // #include "order.c" - return 0; + return 0; }