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
|
{ // this is just a function that returns the total of installed packages
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifndef __APPLE__ // this function is not used on mac os because it causes lots of problems
|
||||||
// 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
|
|
||||||
struct package_manager pkgmans[] = {
|
struct package_manager pkgmans[] = {
|
||||||
{"apt list --installed 2> /dev/null | wc -l", "(apt)"},
|
{"apt list --installed 2> /dev/null | wc -l", "(apt)"},
|
||||||
{"apk info 2> /dev/null | wc -l", "(apk)"},
|
{"apk info 2> /dev/null | wc -l", "(apk)"},
|
||||||
|
@ -238,8 +234,6 @@ int pkgman()
|
||||||
{"rpm -qa --last 2> /dev/null | wc -l", "(rpm)"},
|
{"rpm -qa --last 2> /dev/null | wc -l", "(rpm)"},
|
||||||
{"xbps-query -l 2> /dev/null | wc -l", "(xbps)"},
|
{"xbps-query -l 2> /dev/null | wc -l", "(xbps)"},
|
||||||
{"zypper se --installed-only 2> /dev/null | wc -l", "(zypper)"}};
|
{"zypper se --installed-only 2> /dev/null | wc -l", "(zypper)"}};
|
||||||
#endif
|
|
||||||
|
|
||||||
const unsigned long pkgman_count = sizeof(pkgmans) / sizeof(pkgmans[0]);
|
const unsigned long pkgman_count = sizeof(pkgmans) / sizeof(pkgmans[0]);
|
||||||
|
|
||||||
// to format the pkgman_name string properly
|
// to format the pkgman_name string properly
|
||||||
|
@ -259,7 +253,7 @@ int pkgman()
|
||||||
total += pkg_count;
|
total += pkg_count;
|
||||||
if (pkg_count > 0)
|
if (pkg_count > 0)
|
||||||
{
|
{
|
||||||
if(comma_separator)
|
if (comma_separator)
|
||||||
strcat(pkgman_name, ", ");
|
strcat(pkgman_name, ", ");
|
||||||
comma_separator++;
|
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
|
strcat(pkgman_name, current->pkgman_name); // this is the line that breaks mac os, but something strange happens before
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,9 +318,14 @@ void print_info()
|
||||||
if (show_shell)
|
if (show_shell)
|
||||||
printf("\033[18C%s%sSHEWW %s%s\n",
|
printf("\033[18C%s%sSHEWW %s%s\n",
|
||||||
NORMAL, BOLD, NORMAL, shell);
|
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)
|
if (show_pkgs)
|
||||||
printf("\033[18C%s%sPKGS %s%s%d%s %s\n",
|
printf("\033[18C%s%sPKGS %s%s%d%s %s\n",
|
||||||
NORMAL, BOLD, NORMAL, NORMAL, pkgs, ":", pkgman_name);
|
NORMAL, BOLD, NORMAL, NORMAL, pkgs, ":", pkgman_name);
|
||||||
|
#endif
|
||||||
if (show_uptime)
|
if (show_uptime)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -356,15 +356,16 @@ void get_info()
|
||||||
// os version
|
// os version
|
||||||
FILE *os_release = fopen("/etc/os-release", "r");
|
FILE *os_release = fopen("/etc/os-release", "r");
|
||||||
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
|
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
iscygwin = 1;
|
iscygwin = 1;
|
||||||
#endif
|
#endif
|
||||||
if(iscygwin == 1)
|
if (iscygwin == 1)
|
||||||
sprintf(version_name, "windows");
|
sprintf(version_name, "windows");
|
||||||
|
|
||||||
if (os_release || iscygwin == 1)
|
if (os_release || iscygwin == 1)
|
||||||
{ // get normal vars
|
{ // get normal vars
|
||||||
if(iscygwin == 0) {
|
if (iscygwin == 0)
|
||||||
|
{
|
||||||
while (fgets(line, sizeof(line), os_release))
|
while (fgets(line, sizeof(line), os_release))
|
||||||
if (sscanf(line, "\nID=%s", version_name))
|
if (sscanf(line, "\nID=%s", version_name))
|
||||||
break;
|
break;
|
||||||
|
@ -373,7 +374,7 @@ void get_info()
|
||||||
if (sscanf(line, "model name : %[^\n]", cpu_model))
|
if (sscanf(line, "model name : %[^\n]", cpu_model))
|
||||||
break;
|
break;
|
||||||
sprintf(user, "%s", getenv("USER"));
|
sprintf(user, "%s", getenv("USER"));
|
||||||
if(iscygwin == 0)
|
if (iscygwin == 0)
|
||||||
fclose(os_release);
|
fclose(os_release);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -429,7 +430,7 @@ void get_info()
|
||||||
|
|
||||||
// ram
|
// ram
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef __CYGWIN__
|
#ifndef __CYGWIN__
|
||||||
FILE *meminfo;
|
FILE *meminfo;
|
||||||
|
|
||||||
meminfo = popen("LANG=EN_us free 2> /dev/null", "r");
|
meminfo = popen("LANG=EN_us free 2> /dev/null", "r");
|
||||||
|
@ -449,15 +450,18 @@ void get_info()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(meminfo);
|
fclose(meminfo);
|
||||||
#else
|
#else
|
||||||
//wmic OS get FreePhysicalMemory
|
//wmic OS get FreePhysicalMemory
|
||||||
|
|
||||||
FILE *mem_used_fp, *mem_total_fp;
|
FILE *mem_used_fp, *mem_total_fp;
|
||||||
mem_used_fp = popen("wmic OS GET FreePhysicalMemory | sed -n 2p", "r");
|
mem_used_fp = popen("wmic OS GET FreePhysicalMemory | sed -n 2p", "r");
|
||||||
mem_total_fp = popen("wmic ComputerSystem GET TotalPhysicalMemory | 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];
|
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_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_total_ch, sizeof(mem_total_ch), mem_total_fp) != NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pclose(mem_used_fp);
|
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
|
// 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 = mem_total_ch;
|
||||||
ram_total = ram_total * -1;
|
ram_total = ram_total * -1;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
// Used
|
// Used
|
||||||
FILE *mem_wired_fp, *mem_active_fp, *mem_compressed_fp;
|
FILE *mem_wired_fp, *mem_active_fp, *mem_compressed_fp;
|
||||||
|
@ -520,11 +524,11 @@ void get_info()
|
||||||
if (strcmp(version_name, "android") != 0)
|
if (strcmp(version_name, "android") != 0)
|
||||||
{
|
{
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
gpu = popen("wmic PATH Win32_VideoController GET Name | sed -n 2p", "r");
|
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");
|
gpu = popen("lspci -mm 2> /dev/null | grep \"VGA\" | awk -F '\"' '{print $4 $5 $6}'", "r");
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
gpu = popen("system_profiler SPDisplaysDataType | awk -F ': ' '/Chipset Model: /{ print $2 }'", "r");
|
gpu = popen("system_profiler SPDisplaysDataType | awk -F ': ' '/Chipset Model: /{ print $2 }'", "r");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue