parent
e5d1d26f27
commit
ee077ce0c8
1 changed files with 60 additions and 56 deletions
46
uwufetch.c
46
uwufetch.c
|
@ -220,11 +220,7 @@ int pkgman()
|
|||
{ // this is just a function that returns the total of installed packages
|
||||
int total = 0;
|
||||
|
||||
#ifdef __APPLE__
|
||||
// we use a completely different struct because some commands in the other actually work in mac os, but they are not what you would expect (try running "apt"), but still doesn't work, maybe because of popen()
|
||||
struct package_manager pkgmans[] = {
|
||||
{"ls $(brew --cellar)| wc -l | sed \"s/ //g\" && touch test", "(brew)"}};
|
||||
#else
|
||||
#ifndef __APPLE__ // this function is not used on mac os because it causes lots of problems
|
||||
struct package_manager pkgmans[] = {
|
||||
{"apt list --installed 2> /dev/null | wc -l", "(apt)"},
|
||||
{"apk info 2> /dev/null | wc -l", "(apk)"},
|
||||
|
@ -238,8 +234,6 @@ int pkgman()
|
|||
{"rpm -qa --last 2> /dev/null | wc -l", "(rpm)"},
|
||||
{"xbps-query -l 2> /dev/null | wc -l", "(xbps)"},
|
||||
{"zypper se --installed-only 2> /dev/null | wc -l", "(zypper)"}};
|
||||
#endif
|
||||
|
||||
const unsigned long pkgman_count = sizeof(pkgmans) / sizeof(pkgmans[0]);
|
||||
|
||||
// to format the pkgman_name string properly
|
||||
|
@ -259,7 +253,7 @@ int pkgman()
|
|||
total += pkg_count;
|
||||
if (pkg_count > 0)
|
||||
{
|
||||
if(comma_separator)
|
||||
if (comma_separator)
|
||||
strcat(pkgman_name, ", ");
|
||||
comma_separator++;
|
||||
|
||||
|
@ -270,6 +264,7 @@ int pkgman()
|
|||
strcat(pkgman_name, current->pkgman_name); // this is the line that breaks mac os, but something strange happens before
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return total;
|
||||
}
|
||||
|
||||
|
@ -323,9 +318,14 @@ void print_info()
|
|||
if (show_shell)
|
||||
printf("\033[18C%s%sSHEWW %s%s\n",
|
||||
NORMAL, BOLD, NORMAL, shell);
|
||||
#ifdef __APPLE__
|
||||
if (show_pkgs)
|
||||
system("ls $(brew --cellar) | wc -l | awk -F' ' '{print \" \x1b[34mw w \x1b[0m\x1b[1mPKGS\x1b[0m \"$1 \" (brew)\"}'");
|
||||
#else
|
||||
if (show_pkgs)
|
||||
printf("\033[18C%s%sPKGS %s%s%d%s %s\n",
|
||||
NORMAL, BOLD, NORMAL, NORMAL, pkgs, ":", pkgman_name);
|
||||
#endif
|
||||
if (show_uptime)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
|
@ -356,15 +356,16 @@ void get_info()
|
|||
// os version
|
||||
FILE *os_release = fopen("/etc/os-release", "r");
|
||||
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||
#ifdef __CYGWIN__
|
||||
#ifdef __CYGWIN__
|
||||
iscygwin = 1;
|
||||
#endif
|
||||
if(iscygwin == 1)
|
||||
#endif
|
||||
if (iscygwin == 1)
|
||||
sprintf(version_name, "windows");
|
||||
|
||||
if (os_release || iscygwin == 1)
|
||||
{ // get normal vars
|
||||
if(iscygwin == 0) {
|
||||
if (iscygwin == 0)
|
||||
{
|
||||
while (fgets(line, sizeof(line), os_release))
|
||||
if (sscanf(line, "\nID=%s", version_name))
|
||||
break;
|
||||
|
@ -373,7 +374,7 @@ void get_info()
|
|||
if (sscanf(line, "model name : %[^\n]", cpu_model))
|
||||
break;
|
||||
sprintf(user, "%s", getenv("USER"));
|
||||
if(iscygwin == 0)
|
||||
if (iscygwin == 0)
|
||||
fclose(os_release);
|
||||
}
|
||||
else
|
||||
|
@ -429,7 +430,7 @@ void get_info()
|
|||
|
||||
// ram
|
||||
#ifndef __APPLE__
|
||||
#ifndef __CYGWIN__
|
||||
#ifndef __CYGWIN__
|
||||
FILE *meminfo;
|
||||
|
||||
meminfo = popen("LANG=EN_us free 2> /dev/null", "r");
|
||||
|
@ -449,15 +450,18 @@ void get_info()
|
|||
}
|
||||
}
|
||||
fclose(meminfo);
|
||||
#else
|
||||
#else
|
||||
//wmic OS get FreePhysicalMemory
|
||||
|
||||
FILE *mem_used_fp, *mem_total_fp;
|
||||
mem_used_fp = popen("wmic OS GET FreePhysicalMemory | sed -n 2p", "r");
|
||||
mem_total_fp = popen("wmic ComputerSystem GET TotalPhysicalMemory | sed -n 2p", "r");
|
||||
char mem_used_ch[2137], mem_total_ch[2137];
|
||||
while (fgets(mem_used_ch, sizeof(mem_used_ch), mem_used_fp) != NULL) {
|
||||
while (fgets(mem_total_ch, sizeof(mem_total_ch), mem_total_fp) != NULL) {}
|
||||
while (fgets(mem_used_ch, sizeof(mem_used_ch), mem_used_fp) != NULL)
|
||||
{
|
||||
while (fgets(mem_total_ch, sizeof(mem_total_ch), mem_total_fp) != NULL)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
pclose(mem_used_fp);
|
||||
|
@ -470,7 +474,7 @@ void get_info()
|
|||
// I couldn't get it to show the total amount of ram correctly, so for now this cursed method here
|
||||
ram_total = mem_total_ch;
|
||||
ram_total = ram_total * -1;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
// Used
|
||||
FILE *mem_wired_fp, *mem_active_fp, *mem_compressed_fp;
|
||||
|
@ -520,11 +524,11 @@ void get_info()
|
|||
if (strcmp(version_name, "android") != 0)
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
#ifdef __CYGWIN__
|
||||
#ifdef __CYGWIN__
|
||||
gpu = popen("wmic PATH Win32_VideoController GET Name | sed -n 2p", "r");
|
||||
#else
|
||||
#else
|
||||
gpu = popen("lspci -mm 2> /dev/null | grep \"VGA\" | awk -F '\"' '{print $4 $5 $6}'", "r");
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
gpu = popen("system_profiler SPDisplaysDataType | awk -F ': ' '/Chipset Model: /{ print $2 }'", "r");
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue