parent
e5d1d26f27
commit
ee077ce0c8
1 changed files with 60 additions and 56 deletions
24
uwufetch.c
24
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
|
||||
|
@ -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__
|
||||
|
@ -364,7 +364,8 @@ void get_info()
|
|||
|
||||
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;
|
||||
|
@ -456,8 +457,11 @@ void get_info()
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue