This commit is contained in:
PK 2021-03-07 16:01:41 -06:00
commit 81b813b53f
5 changed files with 83 additions and 24 deletions

View file

@ -7,6 +7,10 @@ all: build install
build: uwufetch.c build: uwufetch.c
gcc $(FLAGS) -o $(NAME) $(FILES) gcc $(FLAGS) -o $(NAME) $(FILES)
debug: build install
clear
./uwufetch
install: install:
sudo cp $(NAME) $(INSTALL_DIR)$(NAME) sudo cp $(NAME) $(INSTALL_DIR)$(NAME)
ls /usr/lib/uwufetch/ > /dev/null || sudo mkdir /usr/lib/uwufetch/ ls /usr/lib/uwufetch/ > /dev/null || sudo mkdir /usr/lib/uwufetch/
@ -16,6 +20,11 @@ uninstall:
sudo rm $(INSTALL_DIR)$(NAME) sudo rm $(INSTALL_DIR)$(NAME)
sudo rm -rf /usr/lib/uwufetch/ sudo rm -rf /usr/lib/uwufetch/
debug: build install termux: build
clear cp $(NAME) /data/data/com.termux/files$(INSTALL_DIR)$(NAME)
./uwufetch ls /data/data/com.termux/files/usr/lib/uwufetch/ > /dev/null || mkdir /data/data/com.termux/files/usr/lib/uwufetch/
cp res/* /data/data/com.termux/files/usr/lib/uwufetch/
termux_uninstall:
rm -rf /data/data/com.termux/files$(INSTALL_DIR)$(NAME)
rm -rf /data/data/com.termux/files/usr/lib/uwufetch/

View file

@ -8,7 +8,14 @@ Nyarch Linuwu, Nyartix Linuwu, Debinyan, Fedowa, GentOwO, Myanjawo.
## Building and installation ## Building and installation
##### Via package manager
Right now the package is only available on the [AUR](https://aur.archlinux.org/packages/uwufetch-git/).
##### Via git clone
To install you can type this commands in the terminal: To install you can type this commands in the terminal:
```shell ```shell
git clone https://github.com/TheDarkBug/uwufetch.git git clone https://github.com/TheDarkBug/uwufetch.git
cd uwufetch cd uwufetch
@ -16,13 +23,28 @@ make
``` ```
To uninstall: To uninstall:
```shell ```shell
cd uwufetch cd uwufetch
make uninstall make uninstall
``` ```
##### Make options:
```shell
make all # builds and installs
make build # builds uwueftch
make debug # use for debug
make install # installs uwufetch
make uninstall # uninstalls uwufetch
make termux # build and install for termux
make termux_uninstall # uninstall for termux
```
## Images ## Images
[IMAGES.md](https://github.com/TheDarkBug/uwufetch/tree/main/res/IMAGES.md) [IMAGES.md](https://github.com/TheDarkBug/uwufetch/tree/main/res/IMAGES.md)
## License ## License
This program is provided under the [GPL-3.0 License](https://github.com/TheDarkBug/uwufetch/LICENSE). This program is provided under the [GPL-3.0 License](https://github.com/TheDarkBug/uwufetch/LICENSE).

View file

@ -22,3 +22,4 @@ If you want to remove *your* image from this repository contact me on [reddit](h
<img src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/tux.png" title="" alt="image" width="200"> Tuwu by u/Annual-Examination96 ([here](https://www.reddit.com/r/linuxmasterrace/comments/lz2i32/tuwu/)) <img src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/tux.png" title="" alt="image" width="200"> Tuwu by u/Annual-Examination96 ([here](https://www.reddit.com/r/linuxmasterrace/comments/lz2i32/tuwu/))
<img src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/ubuntu.png" title="" alt="image" width="200"> Uwuntu by u/Chicki2D ([here](https://www.reddit.com/r/linuxmasterrace/comments/lwsnul/uwuntu/)) <img src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/ubuntu.png" title="" alt="image" width="200"> Uwuntu by u/Chicki2D ([here](https://www.reddit.com/r/linuxmasterrace/comments/lwsnul/uwuntu/))
<img src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/void.png" title="" alt="image" width="200"> Owoid by u/Satoqz ([here](https://www.reddit.com/r/linuxmasterrace/comments/lxnjwd/my_boyfriend_decided_to_create_owoid/)) <img src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/void.png" title="" alt="image" width="200"> Owoid by u/Satoqz ([here](https://www.reddit.com/r/linuxmasterrace/comments/lxnjwd/my_boyfriend_decided_to_create_owoid/))
<img title="" src="https://raw.githubusercontent.com/TheDarkBug/uwufetch/main/res/android.png" alt="image" width="200"> Nyandroid by u/6b86b3ac03c167320d93 ([here](https://www.reddit.com/r/linuxmasterrace/comments/lye15q/im_not_an_artist_but_heres_my_attempt_at_making/)) (android at the end because it could be not considered as an actual distribution of gnu/linux)

BIN
res/android.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -1,3 +1,4 @@
#include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -22,7 +23,7 @@
struct rusage r_usage; struct rusage r_usage;
struct utsname sys_var; struct utsname sys_var;
struct sysinfo sys; struct sysinfo sys;
int ram_max, pkgs; int ram_max, pkgs, a_i_flag = 0;
char user[32], host[253], shell[64], version_name[64], cpu_model[256], pkgman_name[64]; char user[32], host[253], shell[64], version_name[64], cpu_model[256], pkgman_name[64];
int pkgman(); int pkgman();
void get_info(); void get_info();
@ -32,10 +33,8 @@ void print_image();
void usage(char*); void usage(char*);
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int opt = 0, a_i_flag = 0; int opt = 0;
get_info(); get_info();
//sprintf(version_name, "%s", "debian"); // a debug thing
while((opt = getopt(argc, argv, "ad:hi")) != -1) { while((opt = getopt(argc, argv, "ad:hi")) != -1) {
switch(opt) { switch(opt) {
case 'a': case 'a':
@ -95,7 +94,10 @@ int pkgman() { // this is just a function that returns the total of installed pa
} }
void print_info() { // print collected info void print_info() { // print collected info
printf("\033[9A\033[17C %s%s%s@%s\n", NORMAL, BOLD, user, host); char *start_cursor_position = "\033[9A\033[18C";
//if (a_i_flag) start_cursor_position = "\033[8A\033[18C"; // this if - else is for a little bug
//else start_cursor_position = "\033[9A\033[18C";
printf("%s%s%s%s@%s\n", start_cursor_position, NORMAL, BOLD, user, host);
printf("\033[17C %s%sOWOS %s%s\n", NORMAL, BOLD, NORMAL, version_name); printf("\033[17C %s%sOWOS %s%s\n", NORMAL, BOLD, NORMAL, version_name);
printf("\033[17C %s%sKERNEL %s%s %s\n", NORMAL, BOLD, NORMAL, sys_var.release, sys_var.machine); printf("\033[17C %s%sKERNEL %s%s %s\n", NORMAL, BOLD, NORMAL, sys_var.release, sys_var.machine);
printf("\033[17C %s%sCPUWU %s%s\n", NORMAL, BOLD, NORMAL, cpu_model); printf("\033[17C %s%sCPUWU %s%s\n", NORMAL, BOLD, NORMAL, cpu_model);
@ -107,26 +109,45 @@ void print_info() { // print collected info
} }
void get_info() { // get all necessary info void get_info() { // get all necessary info
// os version
FILE *fos_rel = popen("cat /etc/os-release 2> /dev/null | awk '/^ID=/' | awk -F '=' '{print $2}'", "r");
fscanf(fos_rel,"%[^\n]", version_name);
fclose(fos_rel);
if (strlen(version_name) < 1) { // handling unknown distribution
DIR *system_app = opendir("/system/app/");
DIR *system_priv_app = opendir("/system/priv-app/");
if (system_app && system_priv_app) { // android
closedir(system_app);
closedir(system_priv_app);
sprintf(version_name, "android");
} else sprintf(version_name, "generic");
}
// user name, host name and shell // user name, host name and shell
snprintf(user, 32, "%s", getenv("USER")); if (strcmp(version_name, "android") != 0) {
snprintf(user, 32, "%s", getenv("USER"));
// cpu (this is here and not near the ram for efficiency)
FILE *fcpu = popen("lscpu | grep 'Model name:' | cut -d ':' -f2 | sed 's/ //g' 2> /dev/null", "r");
fscanf(fcpu, "%[^\n]", cpu_model);
fclose(fcpu);
}
else if (strcmp(version_name, "android") == 0) { // android vars
FILE *whoami = popen("whoami", "r");
fscanf(whoami, "%s", user);
fclose(whoami);
FILE *fcpu = popen("cat /proc/cpuinfo | grep 'Hardware' | cut -d ':' -f2 | sed 's/ //g' 2> /dev/null", "r");
fscanf(fcpu, "%[^\n]", cpu_model);
fclose(fcpu);
}
gethostname(host, 253); gethostname(host, 253);
snprintf(shell, 16, "%s", getenv("SHELL")); snprintf(shell, 16, "%s", getenv("SHELL"));
memmove(&shell[0], &shell[5], 16); memmove(&shell[0], &shell[5], 16);
// os version
FILE *fos_rel = popen("cat /etc/os-release | awk '/^ID=/' | awk -F '=' '{print $2}' 2> /dev/null", "r");
fscanf(fos_rel,"%[^\n]", version_name);
fclose(fos_rel);
// system info // system info
if (uname(&sys_var) == -1) printf("There was some kind of error while getting the username\n"); if (uname(&sys_var) == -1) printf("There was some kind of error while getting the username\n");
if (sysinfo(&sys) == -1) printf("There was some kind of error while getting system info\n"); if (sysinfo(&sys) == -1) printf("There was some kind of error while getting system info\n");
// cpu and ram // ram
FILE *fcpu = popen("lscpu | grep 'Model name:' | cut -d ':' -f2 | sed 's/ //g' 2> /dev/null", "r");
fscanf(fcpu, "%[^\n]", cpu_model);
fclose(fcpu);
ram_max = sys.totalram * sys.mem_unit / 1048576; ram_max = sys.totalram * sys.mem_unit / 1048576;
getrusage(RUSAGE_SELF, &r_usage); getrusage(RUSAGE_SELF, &r_usage);
pkgs = pkgman(); pkgs = pkgman();
@ -191,7 +212,7 @@ void print_ascii() { // prints logo (as ascii art) of the given system. distribu
" \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n" " \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n"
" \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n" " \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n"
" \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n"); " \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n");
} else if (strcmp(version_name, "\"manjaro-arm\"") == 0) { // we use \ to include the " as the ID on manjaro-arm returns "manjaro-arm" not just manjaro-arm. } else if (strcmp(version_name, "\"manjaro-arm\"") == 0) {
sprintf(version_name, "%s", "Myanjawo AWM"); sprintf(version_name, "%s", "Myanjawo AWM");
printf( "\033[0E\033[1C\u25b3 \u25b3 \u25e0\u25e0\u25e0\u25e0\n" printf( "\033[0E\033[1C\u25b3 \u25b3 \u25e0\u25e0\u25e0\u25e0\n"
" \e[0;42m \e[0m \e[0;42m \e[0m\n" " \e[0;42m \e[0m \e[0;42m \e[0m\n"
@ -201,6 +222,9 @@ void print_ascii() { // prints logo (as ascii art) of the given system. distribu
" \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n" " \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n"
" \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n" " \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n"
" \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n"); " \e[0;42m \e[0m \e[0;42m \e[0m \e[0;42m \e[0m\n");
} else if (strcmp(version_name, "android") == 0) { // android at the end because it could be not considered as an actual distribution of gnu/linux
sprintf(version_name, "%s", "Nyandroid");
printf( "\n\n\nascii icon\n nedds to be\n added\n\n\n\n\n");
} }
// BSD // BSD
@ -231,13 +255,16 @@ void print_image() { // prints logo (as an image) of the given system. distribut
char command[256]; char command[256];
sprintf(command, "viu -t -w 18 -h 8 /usr/lib/uwufetch/%s.png", version_name); sprintf(command, "viu -t -w 18 -h 8 /usr/lib/uwufetch/%s.png", version_name);
system(command); system(command);
printf("\033[1E\033[0C\b");
if (strcmp(version_name, "arch") == 0) sprintf(version_name, "%s", "Nyarch Linuwu"); if (strcmp(version_name, "arch") == 0) sprintf(version_name, "%s", "Nyarch Linuwu");
if (strcmp(version_name, "artix") == 0) sprintf(version_name, "%s", "Nyartix Linuwu"); else if (strcmp(version_name, "artix") == 0) sprintf(version_name, "%s", "Nyartix Linuwu");
if (strcmp(version_name, "debian") == 0) sprintf(version_name, "%s", "Debinyan"); else if (strcmp(version_name, "debian") == 0) sprintf(version_name, "%s", "Debinyan");
if (strcmp(version_name, "fedora") == 0) sprintf(version_name, "%s", "Fedowa"); else if (strcmp(version_name, "fedora") == 0) sprintf(version_name, "%s", "Fedowa");
if (strcmp(version_name, "gentoo") == 0) sprintf(version_name, "%s", "GentOwO"); else if (strcmp(version_name, "gentoo") == 0) sprintf(version_name, "%s", "GentOwO");
if (strcmp(version_name, "manjaro") == 0) sprintf(version_name, "%s", "Myanjawo"); else if (strcmp(version_name, "manjaro") == 0) sprintf(version_name, "%s", "Myanjawo");
else if (strcmp(version_name, "\"manjaro-arm\"") == 0) sprintf(version_name, "%s", "Myanjawo AWM");
else if (strcmp(version_name, "android") == 0) sprintf(version_name, "%s", "Nyandroid"); // android at the end because it could be not considered as an actual distribution of gnu/linux
} }
void usage(char* arg) { void usage(char* arg) {