mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
+3
-1
@@ -78,7 +78,9 @@ void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
|
||||
|
||||
if (colored && !options->pipe)
|
||||
{
|
||||
if(green < yellow)
|
||||
if(percent != percent)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m");
|
||||
else if(green < yellow)
|
||||
{
|
||||
if (percent <= green)
|
||||
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m");
|
||||
|
||||
@@ -27,6 +27,7 @@ const char* ffGetCpuUsageResult(FFlist* result)
|
||||
if(cpuTimes1.length == 0) return "No CPU cores found";
|
||||
|
||||
FF_LIST_AUTO_DESTROY cpuTimes2 = ffListCreate(sizeof(FFCpuUsageInfo));
|
||||
uint32_t retryCount = 0;
|
||||
|
||||
retry:
|
||||
error = ffGetCpuUsageInfo(&cpuTimes2);
|
||||
@@ -39,9 +40,12 @@ retry:
|
||||
FFCpuUsageInfo* cpuTime2 = ffListGet(&cpuTimes2, i);
|
||||
if (cpuTime2->totalAll <= cpuTime1->totalAll)
|
||||
{
|
||||
ffListClear(&cpuTimes2);
|
||||
ffTimeSleep(200);
|
||||
goto retry;
|
||||
if (++retryCount <= 3)
|
||||
{
|
||||
ffListClear(&cpuTimes2);
|
||||
ffTimeSleep(200);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-22
@@ -35,10 +35,10 @@ static bool detectOSCodeName(FFOSResult* os)
|
||||
|
||||
switch (num)
|
||||
{
|
||||
case 14: ffStrbufAppendS(&os->codename, "Sonoma"); return true;
|
||||
case 13: ffStrbufAppendS(&os->codename, "Ventura"); return true;
|
||||
case 12: ffStrbufAppendS(&os->codename, "Monterey"); return true;
|
||||
case 11: ffStrbufAppendS(&os->codename, "Big Sur"); return true;
|
||||
case 14: ffStrbufSetStatic(&os->codename, "Sonoma"); return true;
|
||||
case 13: ffStrbufSetStatic(&os->codename, "Ventura"); return true;
|
||||
case 12: ffStrbufSetStatic(&os->codename, "Monterey"); return true;
|
||||
case 11: ffStrbufSetStatic(&os->codename, "Big Sur"); return true;
|
||||
case 10: {
|
||||
version = str_end + 1;
|
||||
num = strtoul(version, &str_end, 10);
|
||||
@@ -46,23 +46,23 @@ static bool detectOSCodeName(FFOSResult* os)
|
||||
|
||||
switch (num)
|
||||
{
|
||||
case 16: ffStrbufAppendS(&os->codename, "Big Sur"); return true;
|
||||
case 15: ffStrbufAppendS(&os->codename, "Catalina"); return true;
|
||||
case 14: ffStrbufAppendS(&os->codename, "Mojave"); return true;
|
||||
case 13: ffStrbufAppendS(&os->codename, "High Sierra"); return true;
|
||||
case 12: ffStrbufAppendS(&os->codename, "Sierra"); return true;
|
||||
case 11: ffStrbufAppendS(&os->codename, "El Capitan"); return true;
|
||||
case 10: ffStrbufAppendS(&os->codename, "Yosemite"); return true;
|
||||
case 9: ffStrbufAppendS(&os->codename, "Mavericks"); return true;
|
||||
case 8: ffStrbufAppendS(&os->codename, "Mountain Lion"); return true;
|
||||
case 7: ffStrbufAppendS(&os->codename, "Lion"); return true;
|
||||
case 6: ffStrbufAppendS(&os->codename, "Snow Leopard"); return true;
|
||||
case 5: ffStrbufAppendS(&os->codename, "Leopard"); return true;
|
||||
case 4: ffStrbufAppendS(&os->codename, "Tiger"); return true;
|
||||
case 3: ffStrbufAppendS(&os->codename, "Panther"); return true;
|
||||
case 2: ffStrbufAppendS(&os->codename, "Jaguar"); return true;
|
||||
case 1: ffStrbufAppendS(&os->codename, "Puma"); return true;
|
||||
case 0: ffStrbufAppendS(&os->codename, "Cheetah"); return true;
|
||||
case 16: ffStrbufSetStatic(&os->codename, "Big Sur"); return true;
|
||||
case 15: ffStrbufSetStatic(&os->codename, "Catalina"); return true;
|
||||
case 14: ffStrbufSetStatic(&os->codename, "Mojave"); return true;
|
||||
case 13: ffStrbufSetStatic(&os->codename, "High Sierra"); return true;
|
||||
case 12: ffStrbufSetStatic(&os->codename, "Sierra"); return true;
|
||||
case 11: ffStrbufSetStatic(&os->codename, "El Capitan"); return true;
|
||||
case 10: ffStrbufSetStatic(&os->codename, "Yosemite"); return true;
|
||||
case 9: ffStrbufSetStatic(&os->codename, "Mavericks"); return true;
|
||||
case 8: ffStrbufSetStatic(&os->codename, "Mountain Lion"); return true;
|
||||
case 7: ffStrbufSetStatic(&os->codename, "Lion"); return true;
|
||||
case 6: ffStrbufSetStatic(&os->codename, "Snow Leopard"); return true;
|
||||
case 5: ffStrbufSetStatic(&os->codename, "Leopard"); return true;
|
||||
case 4: ffStrbufSetStatic(&os->codename, "Tiger"); return true;
|
||||
case 3: ffStrbufSetStatic(&os->codename, "Panther"); return true;
|
||||
case 2: ffStrbufSetStatic(&os->codename, "Jaguar"); return true;
|
||||
case 1: ffStrbufSetStatic(&os->codename, "Puma"); return true;
|
||||
case 0: ffStrbufSetStatic(&os->codename, "Cheetah"); return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void ffDetectOSImpl(FFOSResult* os)
|
||||
parseSystemVersion(os);
|
||||
|
||||
if(ffStrbufStartsWithIgnCaseS(&os->name, "MacOS"))
|
||||
ffStrbufAppendS(&os->id, "macos");
|
||||
ffStrbufSetStatic(&os->id, "macos");
|
||||
|
||||
if(os->version.length == 0)
|
||||
ffSysctlGetString("kern.osproductversion", &os->version);
|
||||
|
||||
@@ -22,23 +22,27 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
double maxValue = -999, minValue = 999, sumValue = 0;
|
||||
uint32_t maxIndex = 999, minIndex = 999;
|
||||
|
||||
uint32_t index = 0;
|
||||
uint32_t index = 0, valueCount = 0;
|
||||
FF_LIST_FOR_EACH(double, percent, percentages)
|
||||
{
|
||||
sumValue += *percent;
|
||||
if (*percent > maxValue)
|
||||
if (*percent == *percent)
|
||||
{
|
||||
maxValue = *percent;
|
||||
maxIndex = index;
|
||||
}
|
||||
if (*percent < minValue)
|
||||
{
|
||||
minValue = *percent;
|
||||
minIndex = index;
|
||||
sumValue += *percent;
|
||||
if (*percent > maxValue)
|
||||
{
|
||||
maxValue = *percent;
|
||||
maxIndex = index;
|
||||
}
|
||||
if (*percent < minValue)
|
||||
{
|
||||
minValue = *percent;
|
||||
minIndex = index;
|
||||
}
|
||||
++valueCount;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
double avgValue = sumValue / (double) percentages.length;
|
||||
double avgValue = sumValue / (double) valueCount;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user