Added usage, fixed something and added print_image() function (not yet working).

This commit is contained in:
TheDarkBug 2021-03-07 00:19:03 +01:00
parent ae8ec0c57e
commit 7583f23929
4 changed files with 57 additions and 18 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
uwufetch uwufetch
res/*

View file

@ -15,3 +15,7 @@ install:
uninstall: uninstall:
sudo rm $(INSTALL_DIR)$(NAME) sudo rm $(INSTALL_DIR)$(NAME)
rm -rf ~/.config/uwufetch rm -rf ~/.config/uwufetch
debug: build
clear
./uwufetch

View file

@ -4,7 +4,7 @@ A meme system info tool for Linux, based on nyan/UwU trend on r/linuxmasterrace.
## Currently supported distros ## Currently supported distros
Nyarch Linuwu, Nyartix Linuwu, Debinyan, Fedowa, Myanjaro. Nyarch Linuwu, Nyartix Linuwu, Debinyan, Fedowa, Myanjawo.
## Building and installation ## Building and installation

View file

@ -28,14 +28,31 @@ void get_info();
void print_ascii(); void print_ascii();
void print_info(); void print_info();
void print_image(); void print_image();
void usage(char*);
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int opt = getopt(argc, argv, "adhi");
get_info(); get_info();
//sprintf(version_name, "%s", "manjaro"); // a debug thing //sprintf(version_name, "%s", "artix"); // a debug thing
//char c = getopt(argc, argv, "adhi"); // things for the future switch (opt) {
print_ascii(); case 'd':
//system("viu -t -w 18 -h 8 $HOME/.config/uwufetch/arch.png"); // other things for the future usage(argv[0]);
print_info(); return 1;
case 'h':
usage(argv[0]);
return 0;
case 'a':
print_ascii();
break;
case 'i':
print_image();
break;
default:
print_ascii();
break;
}
print_info();
printf("%i\n", opt);
} }
int pkgman() { // this is just a function that returns the total of installed packages int pkgman() { // this is just a function that returns the total of installed packages
@ -60,17 +77,17 @@ int pkgman() { // this is just a function that returns the total of installed pa
fscanf(file[6], "%d", &rpm); fscanf(file[6], "%d", &rpm);
fscanf(file[7], "%d", &xbps); fscanf(file[7], "%d", &xbps);
for (int i = 0; i < 8; i++) fclose(file[i]); for (int i = 0; i < 8; i++) fclose(file[i]);
if (apt > 0) { total += apt; snprintf(pkgman_name, 64, "(%s)", "apt"); } if (apt > 0) { total += apt; strcat(pkgman_name, "(apt)"); }
if (dnf > 0) { total += dnf; snprintf(pkgman_name, 64, "(%s)", "dnf"); } if (dnf > 0) { total += dnf; strcat(pkgman_name, "(dnf)"); }
if (emerge > 0) { total += emerge; snprintf(pkgman_name, 64, "(%s)", "emerge"); } if (emerge > 0) { total += emerge; strcat(pkgman_name, "(emerge)"); }
if (flatpak > 0) { total += flatpak; snprintf(pkgman_name, 64, "(%s)", "flatpak"); } if (flatpak > 0) { total += flatpak; strcat(pkgman_name, "(flatpak)"); }
if (nix > 0) { total += nix; snprintf(pkgman_name, 64, "(%s)", "nix"); } if (nix > 0) { total += nix; strcat(pkgman_name, "(nix)"); }
if (pacman > 0) { total += pacman; snprintf(pkgman_name, 64, "(%s)", "pacman"); } if (pacman > 0) { total += pacman; strcat(pkgman_name, "(pacman)"); }
if (rpm > 0) { total += rpm; snprintf(pkgman_name, 64, "(%s)", "rpm"); } if (rpm > 0) { total += rpm; strcat(pkgman_name, "(rpm)"); }
if (xbps > 0) { total += xbps; snprintf(pkgman_name, 64, "(%s)", "xbps"); } if (xbps > 0) { total += xbps; strcat(pkgman_name, "(xbps)"); }
return total; return total;
} }
void print_info() { // print collected info void print_info() { // print collected info
@ -138,7 +155,7 @@ void print_ascii() {
" -_\n" " -_\n"
" --_\n", RED); " --_\n", RED);
} else if (strcmp(version_name, "fedora") == 0) { } else if (strcmp(version_name, "fedora") == 0) {
sprintf(version_name, "%s", "Fedowora"); sprintf(version_name, "%s", "Fedowoa");
printf( "\033[2;9H%s_____\n" printf( "\033[2;9H%s_____\n"
" / __)%s\\\n" " / __)%s\\\n"
" %s> %s| / %s<%s\\ \\\n" " %s> %s| / %s<%s\\ \\\n"
@ -148,7 +165,7 @@ void print_ascii() {
" %s\\ \\%s__/ |\n" " %s\\ \\%s__/ |\n"
" %s\\%s(_____/\n", BLUE, CYAN, WHITE, BLUE, WHITE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE); " %s\\%s(_____/\n", BLUE, CYAN, WHITE, BLUE, WHITE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE, CYAN, BLUE);
} else if (strcmp(version_name, "manjaro") == 0) { } else if (strcmp(version_name, "manjaro") == 0) {
sprintf(version_name, "%s", "Myanjaro"); sprintf(version_name, "%s", "Myanjawo");
printf( " \u25b3 \u25b3 \u25e0\u25e0\u25e0\u25e0\n" printf( " \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"
" \e[0;42m \e[0m\e[0;42m\e[1;30m > w < \e[0m\e[0;42m \e[0m \e[0;42m \e[0m\n" " \e[0;42m \e[0m\e[0;42m\e[1;30m > w < \e[0m\e[0;42m \e[0m \e[0;42m \e[0m\n"
@ -158,4 +175,21 @@ void print_ascii() {
" \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");
} }
}
void print_image() {
//printf("e[1;1H\e[2J");
char command[256];
sprintf(command, "viu -t -w 18 -h 8 $HOME/.config/uwufetch/%s.png", version_name);
system(command);
}
void usage(char* arg) {
printf("Usage: %s <args>\n"
" -a, --ascii prints logo as ascii text (default)\n"
" -d, --distro %slets you choose the logo to print%s\n"
" -h, --help prints this help page\n"
" -i, --image prints logo as image\n"
" %sworks in few terminals\n"
" <cat README.md> for more info%s\n",
arg, YELLOW, NORMAL, BLUE, NORMAL);
} }