From 3c9d9d113ca75b250d3f03dbd13a0ca65baedeac Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Thu, 22 Jul 2021 19:32:09 -0300 Subject: [PATCH 1/5] Add support for ascii files in files --- Makefile | 2 +- res/ascii/arch.txt | 8 +++++ res/ascii/unknown.txt | 7 +++++ uwufetch.c | 72 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 res/ascii/arch.txt create mode 100644 res/ascii/unknown.txt diff --git a/Makefile b/Makefile index a143f03..55d2de9 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ debug: install: build cp $(NAME) $(DESTDIR)$(PREFIX)/$(NAME) ls $(DESTDIR)$(LIBDIR)/uwufetch > /dev/null || mkdir $(DESTDIR)$(LIBDIR)/uwufetch - cp res/* $(DESTDIR)$(LIBDIR)/uwufetch + cp -r res/* $(DESTDIR)$(LIBDIR)/uwufetch cp ./$(NAME).1.gz $(DESTDIR)$(MANDIR)/ uninstall: diff --git a/res/ascii/arch.txt b/res/ascii/arch.txt new file mode 100644 index 0000000..d4e77f8 --- /dev/null +++ b/res/ascii/arch.txt @@ -0,0 +1,8 @@ +{BLUE} /\ + / \ + /\ \ + / > ω <\ + / __ \ + / __| |__-\ + /_-'' ''-_\ + diff --git a/res/ascii/unknown.txt b/res/ascii/unknown.txt new file mode 100644 index 0000000..6c2e5d6 --- /dev/null +++ b/res/ascii/unknown.txt @@ -0,0 +1,7 @@ +{WHITE} ._.--._. + \|>{YELLOW}_{WHITE}< |/ + |{YELLOW}:_/{WHITE} | + // \ \ ? + (| | ) / + {YELLOW}/'\_ _/`\{WHITE}- + {YELLOW}\___)=(___/ diff --git a/uwufetch.c b/uwufetch.c index 255157e..80154ec 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -101,7 +101,9 @@ int pkgman(); void parse_config(); void get_info(); void list(); +void replace(char *original, char *search, char *replacer); void print_ascii(); +void print_unknown_ascii(); void print_info(); void print_image(); void usage(char *); @@ -623,9 +625,72 @@ void list(char *arg) NORMAL, BLUE, BLUE, PINK, MAGENTA, WHITE, GREEN, YELLOW, BLUE, WHITE); // Other/spare distributions colors } +/* + This replaces all terms in a string with another term. +replace("Hello World!", "World", "everyone") + This returns "Hello everyone!". +*/ +void replace(char *original, char *search, char *replacer) { + char buffer[4096]; + char *ch; + if(!(ch = strstr(original, search))) return; + + strncpy(buffer, original, ch-original); + buffer[ch-original] = 0; + sprintf(buffer+(ch - original), "%s%s", replacer, ch + strlen(search)); + + original[0] = 0; + strcpy(original, buffer); + return replace(original, search, replacer); +} + void print_ascii() { // prints logo (as ascii art) of the given system. distributions listed alphabetically. + printf("\n"); + FILE *file; + char ascii_file[1024]; + // First tries to get ascii art file from local directory. Good when modifying these files. + sprintf(ascii_file, "./res/ascii/%s.txt", version_name); + file = fopen(ascii_file, "r"); + // Now tries to get file from normal directory + if(!file) { + if(strcmp(version_name, "android") == 0) { + sprintf(ascii_file, "/data/data/com.termux/files/usr/lib/uwufetch/ascii/%s.txt", version_name); + } else { + sprintf(ascii_file, "/usr/lib/uwufetch/ascii/%s.txt", version_name); + } + file = fopen(ascii_file, "r"); + if(!file) { + // Prevent infinite loops + if(strcmp(version_name, "unknown") == 0) { + printf("No\nunknown\nascii\nfile\n\n\n\n"); + return; + } + sprintf(version_name, "unknown"); + return print_ascii(); + } + } + char line[64]; + while(fgets(line, 64, file)) { + replace(line, "{NORMAL}", NORMAL); + replace(line, "{BOLD}", BOLD); + replace(line, "{BLACK}", BLACK); + replace(line, "{RED}", RED); + replace(line, "{GREEN}", GREEN); + replace(line, "{YELLOW}", YELLOW); + replace(line, "{BLUE}", BLUE); + replace(line, "{MAGENTA}", MAGENTA); + replace(line, "{CYAN}", CYAN); + replace(line, "{WHITE}", WHITE); + replace(line, "{PINK}", PINK); + replace(line, "{LPINK}", LPINK); + printf(line); + } + // Always set color to NORMAL, so there's no need to do this in every ascii file. + printf(NORMAL); + fclose(file); + /* // linux if (strcmp(version_name, "alpine") == 0) { @@ -871,7 +936,12 @@ void print_ascii() " (| | ) /\n" " %s/'\\_ _/`\\%s-\n" " %s\\___)=(___/\n\n", - WHITE, YELLOW, WHITE, YELLOW, WHITE, YELLOW, WHITE, YELLOW); + WHITE, YELLOW, WHITE, YELLOW, WHITE, YELLOW, WHITE, YELLOW);*/ +} + +void print_unknown_ascii() { + printf("\n\n\n\n\nidk man\n"); + return; } void print_image() From f0342ef54e80bcae7644f1d86cdad6f17a7fb74a Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Thu, 22 Jul 2021 20:33:04 -0300 Subject: [PATCH 2/5] Add arch based distros --- "res/ascii/\"manjaro-arm\".txt" | 8 ++++++++ res/ascii/artix.txt | 8 ++++++++ res/ascii/endeavouros.txt | 7 +++++++ res/ascii/manjaro.txt | 8 ++++++++ uwufetch.c | 8 +++++--- 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 "res/ascii/\"manjaro-arm\".txt" create mode 100644 res/ascii/artix.txt create mode 100644 res/ascii/endeavouros.txt create mode 100644 res/ascii/manjaro.txt diff --git "a/res/ascii/\"manjaro-arm\".txt" "b/res/ascii/\"manjaro-arm\".txt" new file mode 100644 index 0000000..a6c34cf --- /dev/null +++ "b/res/ascii/\"manjaro-arm\".txt" @@ -0,0 +1,8 @@ + △ △ ◠◠◠◠ + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL}{BACKGROUND_GREEN}{BLACK} > ω < {NORMAL}{BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} diff --git a/res/ascii/artix.txt b/res/ascii/artix.txt new file mode 100644 index 0000000..b363ab3 --- /dev/null +++ b/res/ascii/artix.txt @@ -0,0 +1,8 @@ +{BLUE} /\ + / \ + /`'.,\ + /• w • \ + / ,`\ + / ,.'`. \ + /.,'` `'.\ + \ No newline at end of file diff --git a/res/ascii/endeavouros.txt b/res/ascii/endeavouros.txt new file mode 100644 index 0000000..003c84f --- /dev/null +++ b/res/ascii/endeavouros.txt @@ -0,0 +1,7 @@ +{MAGENTA} /\ + {RED}/{MAGENTA}/ \{BLUE}\ + {RED}/{MAGENTA}/>ω<\{BLUE}\ + {RED}/{MAGENTA}/ \ {BLUE}\ + {RED}/ {MAGENTA}/ _) {BLUE}) + {RED}/_{MAGENTA}/___-- {BLUE}___- + /____--- diff --git a/res/ascii/manjaro.txt b/res/ascii/manjaro.txt new file mode 100644 index 0000000..a6c34cf --- /dev/null +++ b/res/ascii/manjaro.txt @@ -0,0 +1,8 @@ + △ △ ◠◠◠◠ + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL}{BACKGROUND_GREEN}{BLACK} > ω < {NORMAL}{BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} + {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} {BACKGROUND_GREEN} {NORMAL} diff --git a/uwufetch.c b/uwufetch.c index 80154ec..e7797f5 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -631,7 +631,7 @@ replace("Hello World!", "World", "everyone") This returns "Hello everyone!". */ void replace(char *original, char *search, char *replacer) { - char buffer[4096]; + char buffer[1024]; char *ch; if(!(ch = strstr(original, search))) return; @@ -670,8 +670,8 @@ void print_ascii() return print_ascii(); } } - char line[64]; - while(fgets(line, 64, file)) { + char line[256]; + while(fgets(line, 256, file)) { replace(line, "{NORMAL}", NORMAL); replace(line, "{BOLD}", BOLD); replace(line, "{BLACK}", BLACK); @@ -684,6 +684,8 @@ void print_ascii() replace(line, "{WHITE}", WHITE); replace(line, "{PINK}", PINK); replace(line, "{LPINK}", LPINK); + // For manjaro + replace(line, "{BACKGROUND_GREEN}", "\e[0;42m"); printf(line); } // Always set color to NORMAL, so there's no need to do this in every ascii file. From b881e63fc65e10faec649fcfda472bfc3cb41e75 Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Thu, 22 Jul 2021 20:51:02 -0300 Subject: [PATCH 3/5] Add debian based distros --- res/ascii/debian.txt | 8 ++++++++ res/ascii/linuxmint.txt | 7 +++++++ res/ascii/pop.txt | 7 +++++++ res/ascii/raspbian.txt | 7 +++++++ res/ascii/ubuntu.txt | 7 +++++++ 5 files changed, 36 insertions(+) create mode 100644 res/ascii/debian.txt create mode 100644 res/ascii/linuxmint.txt create mode 100644 res/ascii/pop.txt create mode 100644 res/ascii/raspbian.txt create mode 100644 res/ascii/ubuntu.txt diff --git a/res/ascii/debian.txt b/res/ascii/debian.txt new file mode 100644 index 0000000..54a85ea --- /dev/null +++ b/res/ascii/debian.txt @@ -0,0 +1,8 @@ +{RED} ______ + / ___ \ + | / OωO | + | \____- + -_ + --_\ + + \ No newline at end of file diff --git a/res/ascii/linuxmint.txt b/res/ascii/linuxmint.txt new file mode 100644 index 0000000..7c26c13 --- /dev/null +++ b/res/ascii/linuxmint.txt @@ -0,0 +1,7 @@ +{GREEN} __/\____/\. + |{WHITE}.--. {GREEN}| + {WHITE}, {GREEN}¯| {WHITE}| UωU| {GREEN}| + {WHITE}|| {GREEN}| {WHITE}| | {GREEN}| + {WHITE} | {GREEN}| {WHITE}---- {GREEN}| + {WHITE} --{GREEN}'--------' + diff --git a/res/ascii/pop.txt b/res/ascii/pop.txt new file mode 100644 index 0000000..fef44af --- /dev/null +++ b/res/ascii/pop.txt @@ -0,0 +1,7 @@ +{BLUE} |\.-----./| + |/ \| + | > < | + | {LPINK}~ {WHITE}P! {LPINK}~ {BLUE}| +_ ---\ ω / + \_/ '-----' + diff --git a/res/ascii/raspbian.txt b/res/ascii/raspbian.txt new file mode 100644 index 0000000..2bec710 --- /dev/null +++ b/res/ascii/raspbian.txt @@ -0,0 +1,7 @@ +{GREEN} __ __ + (_\)(/_) + {RED}(>(__)<) + (_(_)(_)_) + (_(__)_) + (__) + diff --git a/res/ascii/ubuntu.txt b/res/ascii/ubuntu.txt new file mode 100644 index 0000000..7ed4cb8 --- /dev/null +++ b/res/ascii/ubuntu.txt @@ -0,0 +1,7 @@ +{LPINK} _ + {PINK}◣{LPINK}__(_){PINK}◢{LPINK} + _/ --- \ + (_) |>ω<| | + \ --- _/ + {PINK}C__/{LPINK}---(_) + From f0a40267f3861efcda861e6a71c3cad092c07f16 Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Fri, 30 Jul 2021 19:05:27 -0300 Subject: [PATCH 4/5] Add BSD distros --- res/ascii/freebsd.txt | 8 ++++++++ res/ascii/macos.txt | 8 ++++++++ res/ascii/openbsd.txt | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 res/ascii/freebsd.txt create mode 100644 res/ascii/macos.txt create mode 100644 res/ascii/openbsd.txt diff --git a/res/ascii/freebsd.txt b/res/ascii/freebsd.txt new file mode 100644 index 0000000..3b44a43 --- /dev/null +++ b/res/ascii/freebsd.txt @@ -0,0 +1,8 @@ + + {RED}/\,-'''''-,/\ + \_) (_/ + | \ / | + | O ω O | + ; ; + '-_____-' + diff --git a/res/ascii/macos.txt b/res/ascii/macos.txt new file mode 100644 index 0000000..552873e --- /dev/null +++ b/res/ascii/macos.txt @@ -0,0 +1,8 @@ + {GREEN} .:` + .--``--. +{YELLOW} ww OωO w +{RED} w w +{PINK} w w + +{BLUE} www_-_www + diff --git a/res/ascii/openbsd.txt b/res/ascii/openbsd.txt new file mode 100644 index 0000000..0aaf295 --- /dev/null +++ b/res/ascii/openbsd.txt @@ -0,0 +1,8 @@ + + {YELLOW} ______ + \- -/ {RED}♥ +{YELLOW}\_/ \ +| {WHITE}> < {YELLOW}| +|_ < {LPINK}// {WHITE}ω {LPINK}// +{YELLOW}/ \ / + /-________-\ From 52c4694bcebc8a4de48554ae8584fb9bba25c818 Mon Sep 17 00:00:00 2001 From: Guaxinim5573 Date: Fri, 30 Jul 2021 19:52:09 -0300 Subject: [PATCH 5/5] Add other/spare distros --- res/ascii/alpine.txt | 8 ++++++++ res/ascii/android.txt | 8 ++++++++ res/ascii/fedora.txt | 8 ++++++++ res/ascii/gentoo.txt | 8 ++++++++ res/ascii/gnu.txt | 8 ++++++++ res/ascii/guix.txt | 8 ++++++++ res/ascii/opensuse-leap.txt | 8 ++++++++ res/ascii/slackware.txt | 8 ++++++++ res/ascii/solus.txt | 8 ++++++++ res/ascii/void.txt | 8 ++++++++ res/ascii/windows.txt | 9 +++++++++ 11 files changed, 89 insertions(+) create mode 100644 res/ascii/alpine.txt create mode 100644 res/ascii/android.txt create mode 100644 res/ascii/fedora.txt create mode 100644 res/ascii/gentoo.txt create mode 100644 res/ascii/gnu.txt create mode 100644 res/ascii/guix.txt create mode 100644 res/ascii/opensuse-leap.txt create mode 100644 res/ascii/slackware.txt create mode 100644 res/ascii/solus.txt create mode 100644 res/ascii/void.txt create mode 100644 res/ascii/windows.txt diff --git a/res/ascii/alpine.txt b/res/ascii/alpine.txt new file mode 100644 index 0000000..41409b6 --- /dev/null +++ b/res/ascii/alpine.txt @@ -0,0 +1,8 @@ + + {BLUE}. .___. + / \/ \ / + /OωO\ɛU\/ __ + / \ \__/ \ +/ \ \ + + diff --git a/res/ascii/android.txt b/res/ascii/android.txt new file mode 100644 index 0000000..6045cfc --- /dev/null +++ b/res/ascii/android.txt @@ -0,0 +1,8 @@ + + {GREEN}\ _------_ / + / \ + | {RED}~ {GREEN}> ω < {RED}~ {GREEN}| + ------------ + + + diff --git a/res/ascii/fedora.txt b/res/ascii/fedora.txt new file mode 100644 index 0000000..f38e0e2 --- /dev/null +++ b/res/ascii/fedora.txt @@ -0,0 +1,8 @@ + {BLUE}_____ + / __){CYAN}\ + {WHITE}> {BLUE}| / {WHITE}<{CYAN}\ \ + __{BLUE}_| {CYAN}ω{BLUE}|_{CYAN}_/ / + / {BLUE}(_ _){CYAN}_/ + / / {BLUE}| | + {CYAN}\ \{BLUE}__/ | + {CYAN}\{BLUE}(_____/ diff --git a/res/ascii/gentoo.txt b/res/ascii/gentoo.txt new file mode 100644 index 0000000..7924ef4 --- /dev/null +++ b/res/ascii/gentoo.txt @@ -0,0 +1,8 @@ + {MAGENTA}_-----_ + ( \\ + \\ OωO \\ +{WHITE} \\ ) + / _/ + ( _- + \\____- + diff --git a/res/ascii/gnu.txt b/res/ascii/gnu.txt new file mode 100644 index 0000000..eea2a71 --- /dev/null +++ b/res/ascii/gnu.txt @@ -0,0 +1,8 @@ + + + {WHITE},= {YELLOW},-_-. {WHITE}=. + ((_/{YELLOW}){WHITE}U U{YELLOW}({WHITE}\_)) + `-'{YELLOW}(. .){WHITE}`-' + {YELLOW}\{WHITE}w{YELLOW}/ + ¯ + diff --git a/res/ascii/guix.txt b/res/ascii/guix.txt new file mode 100644 index 0000000..eea2a71 --- /dev/null +++ b/res/ascii/guix.txt @@ -0,0 +1,8 @@ + + + {WHITE},= {YELLOW},-_-. {WHITE}=. + ((_/{YELLOW}){WHITE}U U{YELLOW}({WHITE}\_)) + `-'{YELLOW}(. .){WHITE}`-' + {YELLOW}\{WHITE}w{YELLOW}/ + ¯ + diff --git a/res/ascii/opensuse-leap.txt b/res/ascii/opensuse-leap.txt new file mode 100644 index 0000000..57bf9bf --- /dev/null +++ b/res/ascii/opensuse-leap.txt @@ -0,0 +1,8 @@ + + + {GREEN}|\----/| + _ / {WHITE}O O{GREEN}\ + __. ω / + '----' + + diff --git a/res/ascii/slackware.txt b/res/ascii/slackware.txt new file mode 100644 index 0000000..78cd4f5 --- /dev/null +++ b/res/ascii/slackware.txt @@ -0,0 +1,8 @@ + + {MAGENTA}|\.-----./| + |/ \| + | > < | + | {LPINK}~ {WHITE}S {LPINK}~ {MAGENTA}| +_ ---\ ω / + \_/ '-----' + diff --git a/res/ascii/solus.txt b/res/ascii/solus.txt new file mode 100644 index 0000000..8f6b540 --- /dev/null +++ b/res/ascii/solus.txt @@ -0,0 +1,8 @@ + + {WHITE}|\.-----./| + | \ / | + |/ > <\ | + |{BLUE}_{LPINK}~{BLUE}_____{LPINK}~{WHITE}\| +{BLUE}_ ---\ {WHITE}ω {BLUE}/ + \_/ '-----' + diff --git a/res/ascii/void.txt b/res/ascii/void.txt new file mode 100644 index 0000000..56e7b7c --- /dev/null +++ b/res/ascii/void.txt @@ -0,0 +1,8 @@ + + {GREEN} |\_____/| + _\____ | + | \ \ | + | | {WHITE}ÒωÓ {GREEN}| | , + | \_____\_|-, | + -_______\ \_/ + diff --git a/res/ascii/windows.txt b/res/ascii/windows.txt new file mode 100644 index 0000000..8781ffe --- /dev/null +++ b/res/ascii/windows.txt @@ -0,0 +1,9 @@ +{BLUE}MMMMMMM MMMMMMM +M ^ M M ^ M +M M M M +MMMMMMM MMMMMMM + +MMMMMMM MMMMMMM +M W W W M +M WW WW M +MMMMMMM MMMMMMM