mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
CPUUsage / DiskIO / NetIO: add option waitTime
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY percentages = ffListCreate(sizeof(double));
|
||||
const char* error = ffGetCpuUsageResult(&percentages);
|
||||
const char* error = ffGetCpuUsageResult(options, &percentages);
|
||||
|
||||
if(error)
|
||||
{
|
||||
@@ -111,6 +111,12 @@ bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "wait-time"))
|
||||
{
|
||||
options->waitTime = ffOptionParseUInt32(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffPercentParseCommandOptions(key, subKey, value, &options->percent))
|
||||
return true;
|
||||
|
||||
@@ -136,6 +142,12 @@ void ffParseCPUUsageJsonObject(FFCPUUsageOptions* options, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "waitTime"))
|
||||
{
|
||||
options->waitTime = (uint32_t) yyjson_get_uint(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffPercentParseJsonObject(key, val, &options->percent))
|
||||
continue;
|
||||
|
||||
@@ -156,10 +168,10 @@ void ffGenerateCPUUsageJsonConfig(FFCPUUsageOptions* options, yyjson_mut_doc* do
|
||||
ffPercentGenerateJsonConfig(doc, module, defaultOptions.percent, options->percent);
|
||||
}
|
||||
|
||||
void ffGenerateCPUUsageJsonResult(FF_MAYBE_UNUSED FFCPUUsageOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
void ffGenerateCPUUsageJsonResult(FFCPUUsageOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY percentages = ffListCreate(sizeof(double));
|
||||
const char* error = ffGetCpuUsageResult(&percentages);
|
||||
const char* error = ffGetCpuUsageResult(options, &percentages);
|
||||
|
||||
if(error)
|
||||
{
|
||||
@@ -203,6 +215,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->separate = false;
|
||||
options->percent = (FFColorRangeConfig) { 50, 80 };
|
||||
options->waitTime = 200;
|
||||
}
|
||||
|
||||
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
|
||||
@@ -12,4 +12,5 @@ typedef struct FFCPUUsageOptions
|
||||
|
||||
bool separate;
|
||||
FFColorRangeConfig percent;
|
||||
uint32_t waitTime; // in ms
|
||||
} FFCPUUsageOptions;
|
||||
|
||||
@@ -115,6 +115,12 @@ bool ffParseDiskIOCommandOptions(FFDiskIOOptions* options, const char* key, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "wait-time"))
|
||||
{
|
||||
options->waitTime = ffOptionParseUInt32(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -143,6 +149,12 @@ void ffParseDiskIOJsonObject(FFDiskIOOptions* options, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "waitTime"))
|
||||
{
|
||||
options->waitTime = (uint32_t) yyjson_get_uint(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_DISKIO_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
@@ -222,6 +234,7 @@ void ffInitDiskIOOptions(FFDiskIOOptions* options)
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
options->detectTotal = false;
|
||||
options->waitTime = 1000;
|
||||
}
|
||||
|
||||
void ffDestroyDiskIOOptions(FFDiskIOOptions* options)
|
||||
|
||||
@@ -10,5 +10,6 @@ typedef struct FFDiskIOOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFstrbuf namePrefix;
|
||||
uint32_t waitTime;
|
||||
bool detectTotal;
|
||||
} FFDiskIOOptions;
|
||||
|
||||
@@ -129,6 +129,12 @@ bool ffParseNetIOCommandOptions(FFNetIOOptions* options, const char* key, const
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subKey, "wait-time"))
|
||||
{
|
||||
options->waitTime = ffOptionParseUInt32(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -163,6 +169,12 @@ void ffParseNetIOJsonObject(FFNetIOOptions* options, yyjson_val* module)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(key, "waitTime"))
|
||||
{
|
||||
options->waitTime = (uint32_t) yyjson_get_uint(val);
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_NETIO_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
@@ -259,6 +271,7 @@ void ffInitNetIOOptions(FFNetIOOptions* options)
|
||||
#endif
|
||||
;
|
||||
options->detectTotal = false;
|
||||
options->waitTime = 1000;
|
||||
}
|
||||
|
||||
void ffDestroyNetIOOptions(FFNetIOOptions* options)
|
||||
|
||||
@@ -10,6 +10,7 @@ typedef struct FFNetIOOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFstrbuf namePrefix;
|
||||
uint32_t waitTime;
|
||||
bool defaultRouteOnly;
|
||||
bool detectTotal;
|
||||
} FFNetIOOptions;
|
||||
|
||||
Reference in New Issue
Block a user