From a695c922f4951b16adfa2dac810dadb25de50cfb Mon Sep 17 00:00:00 2001 From: TheDarkBug Date: Tue, 16 Mar 2021 09:10:54 +0100 Subject: [PATCH] Theoretically fixed gpu name being too long, new 'Requisites' in readme, now uwufetch depends from lshw --- README.md | 5 +++++ uwufetch.c | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6cea587..8d1504a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,11 @@ Nyalpine, Nyarch Linuwu, Nyartix Linuwu, Debinyan, Fedowa, GentOwO, Miwint, Myan ## Building and installation +#### Requisites + +[viu](https://github.com/atanunq/viu) to use images instead of ascii art. +[lshw](https://github.com/lyonel/lshw) to get gpu info. + ##### Via package manager Right now, the package is only available on the AUR: diff --git a/uwufetch.c b/uwufetch.c index 5361803..7c38c60 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -156,10 +156,7 @@ void get_info() { // get all necessary info FILE *os_release = fopen("/etc/os-release", "r"); FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); if (os_release) { // get normal vars - while (fgets(line, sizeof(line), os_release)) { - sscanf(line, "\nID=%s", version_name); - if (strlen(version_name)) break; - } + while (fgets(line, sizeof(line), os_release)) if (sscanf(line, "\nID=%s", version_name)) break; while (fgets(line, sizeof(line), cpuinfo)) if (sscanf(line, "model name : %[^\n]", cpu_model)) break; sprintf(user, "%s", getenv("USER")); fclose(os_release); @@ -174,7 +171,7 @@ void get_info() { // get all necessary info FILE *whoami = popen("whoami", "r"); if (fscanf(whoami, "%s", user) == 3) sprintf(user, "unknown"); fclose(whoami); - while (fgets(line, sizeof(line), cpuinfo)) if (fscanf(cpuinfo, "Hardware : %[^\n]", cpu_model)) break; + while (fgets(line, sizeof(line), cpuinfo)) if (sscanf(line, "Hardware : %[^\n]", cpu_model)) break; } else sprintf(version_name, "unknown"); } fclose(cpuinfo); @@ -200,13 +197,14 @@ void get_info() { // get all necessary info // gpu FILE *gpu; - if (strcmp(version_name, "android") != 0) gpu = popen("lspci -mm | grep \"VGA\\|00:02\" | cut --fields=4,6 -d '\"' --output-delimiter=\" \" | sed \"s/ Controller.*//\"", "r"); - else gpu = popen("getprop ro.hardware.vulkan", "r"); - if (gpu) { - // Ignore error - if(fscanf(gpu, "%[^\n]", gpu_model) == 3) {}; - fclose(gpu); + gpu = popen("lshw -class display 2> /dev/null", "r"); + while (fgets(line, sizeof(line), gpu)) if (sscanf(line, " product: %[^\n]", gpu_model)) break; + if (strlen(gpu_model) < 1) { + if (strcmp(version_name, "android") != 0) gpu = popen("lspci -mm 2> /dev/null | grep \"VGA\\|00:02\" | cut --fields=4,6 -d '\"' --output-delimiter=\" \" | sed \"s/ Controller.*//\"", "r"); + else gpu = popen("getprop ro.hardware.vulkan 2> /dev/null", "r"); + while (fgets(line, sizeof(line), gpu)) if (sscanf(line, "%[^\n]", gpu_model)) break; } + fclose(gpu); pkgs = pkgman(); }