mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
Global: add new unit related options
1. `--<module>-space-before-unit` 2. `--duration-abbreviation` 3. various code refactoring and cleanups
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/duration.h"
|
||||
#include "common/temps.h"
|
||||
#include "detection/battery/battery.h"
|
||||
#include "modules/battery/battery.h"
|
||||
@@ -59,7 +59,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendS(&str, " (");
|
||||
|
||||
ffParseDuration((uint32_t) result->timeRemaining, &str);
|
||||
ffDurationAppendNum((uint32_t) result->timeRemaining, &str);
|
||||
ffStrbufAppendS(&str, " remaining)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/btrfs/btrfs.h"
|
||||
#include "modules/btrfs/btrfs.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -34,11 +35,11 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(used, &usedPretty);
|
||||
ffSizeAppendNum(used, &usedPretty);
|
||||
FF_STRBUF_AUTO_DESTROY allocatedPretty = ffStrbufCreate();
|
||||
ffParseSize(allocated, &allocatedPretty);
|
||||
ffSizeAppendNum(allocated, &allocatedPretty);
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(total, &totalPretty);
|
||||
ffSizeAppendNum(total, &totalPretty);
|
||||
|
||||
double usedPercentage = total > 0 ? (double) used / (double) total * 100.0 : 0;
|
||||
double allocatedPercentage = total > 0 ? (double) allocated / (double) total * 100.0 : 0;
|
||||
@@ -74,9 +75,9 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i
|
||||
ffPercentAppendBar(&allocatedPercentageBar, allocatedPercentage, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY nodeSizePretty = ffStrbufCreate();
|
||||
ffParseSize(result->nodeSize, &nodeSizePretty);
|
||||
ffSizeAppendNum(result->nodeSize, &nodeSizePretty);
|
||||
FF_STRBUF_AUTO_DESTROY sectorSizePretty = ffStrbufCreate();
|
||||
ffParseSize(result->sectorSize, §orSizePretty);
|
||||
ffSizeAppendNum(result->sectorSize, §orSizePretty);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/temps.h"
|
||||
#include "common/frequency.h"
|
||||
#include "detection/cpu/cpu.h"
|
||||
#include "modules/cpu/cpu.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -77,7 +78,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
if(freq > 0)
|
||||
{
|
||||
ffStrbufAppendS(&str, " @ ");
|
||||
ffParseFrequency(freq, &str);
|
||||
ffFreqAppendNum(freq, &str);
|
||||
}
|
||||
|
||||
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
|
||||
@@ -91,9 +92,9 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY freqBase = ffStrbufCreate();
|
||||
ffParseFrequency(cpu.frequencyBase, &freqBase);
|
||||
ffFreqAppendNum(cpu.frequencyBase, &freqBase);
|
||||
FF_STRBUF_AUTO_DESTROY freqMax = ffStrbufCreate();
|
||||
ffParseFrequency(cpu.frequencyMax, &freqMax);
|
||||
ffFreqAppendNum(cpu.frequencyMax, &freqMax);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/cpucache/cpucache.h"
|
||||
#include "modules/cpucache/cpucache.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -45,7 +46,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
|
||||
ffStrbufAppendS(&buffer, ", ");
|
||||
if (src->num > 1)
|
||||
ffStrbufAppendF(&buffer, "%ux", src->num);
|
||||
ffParseSize(src->size, &buffer);
|
||||
ffSizeAppendNum(src->size, &buffer);
|
||||
ffStrbufAppendF(&buffer, " (%c)", typeStr);
|
||||
|
||||
sum += src->size * src->num;
|
||||
@@ -59,7 +60,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
|
||||
ffParseSize(sum, &buffer2);
|
||||
ffSizeAppendNum(sum, &buffer2);
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buffer, "result"),
|
||||
FF_FORMAT_ARG(buffer2, "sum"),
|
||||
@@ -79,7 +80,7 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio
|
||||
uint32_t value = 0;
|
||||
FF_LIST_FOR_EACH(FFCPUCache, src, result->caches[i])
|
||||
value += src->size * src->num;
|
||||
ffParseSize(value, &buffer);
|
||||
ffSizeAppendNum(value, &buffer);
|
||||
ffStrbufAppendF(&buffer, " (L%u)", i + 1);
|
||||
sum += value;
|
||||
}
|
||||
@@ -92,7 +93,7 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
|
||||
ffParseSize(sum, &buffer2);
|
||||
ffSizeAppendNum(sum, &buffer2);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buffer, "result"),
|
||||
FF_FORMAT_ARG(buffer2, "sum"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/size.h"
|
||||
#include "common/time.h"
|
||||
#include "detection/disk/disk.h"
|
||||
#include "modules/disk/disk.h"
|
||||
@@ -44,10 +44,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(disk->bytesUsed, &usedPretty);
|
||||
ffSizeAppendNum(disk->bytesUsed, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(disk->bytesTotal, &totalPretty);
|
||||
ffSizeAppendNum(disk->bytesTotal, &totalPretty);
|
||||
|
||||
double bytesPercentage = disk->bytesTotal > 0 ? (double) disk->bytesUsed / (double) disk->bytesTotal * 100.0 : 0;
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/diskio/diskio.h"
|
||||
#include "modules/diskio/diskio.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -57,21 +57,21 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
|
||||
{
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
ffParseSize(dev->bytesRead, &buffer);
|
||||
ffSizeAppendNum(dev->bytesRead, &buffer);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
ffStrbufAppendS(&buffer, " (R) - ");
|
||||
|
||||
ffParseSize(dev->bytesWritten, &buffer);
|
||||
ffSizeAppendNum(dev->bytesWritten, &buffer);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
ffStrbufAppendS(&buffer, " (W)");
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffParseSize(dev->bytesRead, &buffer);
|
||||
ffSizeAppendNum(dev->bytesRead, &buffer);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
ffStrbufClear(&buffer2);
|
||||
ffParseSize(dev->bytesWritten, &buffer2);
|
||||
ffSizeAppendNum(dev->bytesWritten, &buffer2);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "modules/display/display.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -51,10 +52,11 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
{
|
||||
if (result->refreshRate > 0)
|
||||
{
|
||||
const char* space = instance.config.display.freqSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_ALWAYS ? " " : "";
|
||||
if (options->preciseRefreshRate)
|
||||
ffStrbufAppendF(&buffer, " @ %gHz", result->refreshRate);
|
||||
ffStrbufAppendF(&buffer, " @ %g%sHz", result->refreshRate, space);
|
||||
else
|
||||
ffStrbufAppendF(&buffer, " @ %iHz", (uint32_t) (result->refreshRate + 0.5));
|
||||
ffStrbufAppendF(&buffer, " @ %i%sHz", (uint32_t) (result->refreshRate + 0.5), space);
|
||||
}
|
||||
ffStrbufAppendS(&buffer, ", ");
|
||||
}
|
||||
@@ -108,10 +110,11 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
|
||||
if(result->refreshRate > 0)
|
||||
{
|
||||
const char* space = instance.config.display.freqSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_NEVER ? "" : " ";
|
||||
if(options->preciseRefreshRate)
|
||||
ffStrbufAppendF(&buffer, " @ %g Hz", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0);
|
||||
ffStrbufAppendF(&buffer, " @ %g%sHz", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0, space);
|
||||
else
|
||||
ffStrbufAppendF(&buffer, " @ %i Hz", (uint32_t) (result->refreshRate + 0.5));
|
||||
ffStrbufAppendF(&buffer, " @ %i%sHz", (uint32_t) (result->refreshRate + 0.5), space);
|
||||
}
|
||||
|
||||
if(
|
||||
|
||||
+10
-9
@@ -1,8 +1,9 @@
|
||||
#include "common/percent.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/temps.h"
|
||||
#include "common/size.h"
|
||||
#include "common/frequency.h"
|
||||
#include "detection/host/host.h"
|
||||
#include "detection/gpu/gpu.h"
|
||||
#include "modules/gpu/gpu.h"
|
||||
@@ -42,7 +43,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
if(gpu->frequency > 0)
|
||||
{
|
||||
ffStrbufAppendS(&output, " @ ");
|
||||
ffParseFrequency(gpu->frequency, &output);
|
||||
ffFreqAppendNum(gpu->frequency, &output);
|
||||
}
|
||||
|
||||
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
|
||||
@@ -59,10 +60,10 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
{
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffParseSize(gpu->dedicated.used, &output);
|
||||
ffSizeAppendNum(gpu->dedicated.used, &output);
|
||||
ffStrbufAppendS(&output, " / ");
|
||||
}
|
||||
ffParseSize(gpu->dedicated.total, &output);
|
||||
ffSizeAppendNum(gpu->dedicated.total, &output);
|
||||
}
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
@@ -94,8 +95,8 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
FF_STRBUF_AUTO_DESTROY dUsed = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY dPercentNum = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY dPercentBar = ffStrbufCreate();
|
||||
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET) ffParseSize(gpu->dedicated.total, &dTotal);
|
||||
if (gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) ffParseSize(gpu->dedicated.used, &dUsed);
|
||||
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET) ffSizeAppendNum(gpu->dedicated.total, &dTotal);
|
||||
if (gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET) ffSizeAppendNum(gpu->dedicated.used, &dUsed);
|
||||
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET && gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
double percent = (double) gpu->dedicated.used / (double) gpu->dedicated.total * 100.0;
|
||||
@@ -109,8 +110,8 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
FF_STRBUF_AUTO_DESTROY sUsed = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY sPercentNum = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY sPercentBar = ffStrbufCreate();
|
||||
if (gpu->shared.total != FF_GPU_VMEM_SIZE_UNSET) ffParseSize(gpu->shared.total, &sTotal);
|
||||
if (gpu->shared.used != FF_GPU_VMEM_SIZE_UNSET) ffParseSize(gpu->shared.used, &sUsed);
|
||||
if (gpu->shared.total != FF_GPU_VMEM_SIZE_UNSET) ffSizeAppendNum(gpu->shared.total, &sTotal);
|
||||
if (gpu->shared.used != FF_GPU_VMEM_SIZE_UNSET) ffSizeAppendNum(gpu->shared.used, &sUsed);
|
||||
if (gpu->shared.total != FF_GPU_VMEM_SIZE_UNSET && gpu->shared.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
double percent = (double) gpu->shared.used / (double) gpu->shared.total * 100.0;
|
||||
@@ -121,7 +122,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY frequency = ffStrbufCreate();
|
||||
ffParseFrequency(gpu->frequency, &frequency);
|
||||
ffFreqAppendNum(gpu->frequency, &frequency);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY coreUsageNum = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY coreUsageBar = ffStrbufCreate();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/size.h"
|
||||
#include "modules/kernel/kernel.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
@@ -19,7 +20,7 @@ void ffPrintKernel(FFKernelOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
ffParseSize(info->pageSize, &str);
|
||||
ffSizeAppendNum(info->pageSize, &str);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(info->name, "sysname"),
|
||||
FF_FORMAT_ARG(info->release, "release"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/memory/memory.h"
|
||||
#include "modules/memory/memory.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -18,10 +18,10 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesUsed, &usedPretty);
|
||||
ffSizeAppendNum(storage.bytesUsed, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(storage.bytesTotal, &totalPretty);
|
||||
ffSizeAppendNum(storage.bytesTotal, &totalPretty);
|
||||
|
||||
double percentage = storage.bytesTotal == 0
|
||||
? 0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/netio/netio.h"
|
||||
#include "modules/netio/netio.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -59,11 +59,11 @@ void ffPrintNetIO(FFNetIOOptions* options)
|
||||
{
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
ffParseSize(inf->rxBytes, &buffer);
|
||||
ffSizeAppendNum(inf->rxBytes, &buffer);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
ffStrbufAppendS(&buffer, " (IN) - ");
|
||||
|
||||
ffParseSize(inf->txBytes, &buffer);
|
||||
ffSizeAppendNum(inf->txBytes, &buffer);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
ffStrbufAppendS(&buffer, " (OUT)");
|
||||
|
||||
@@ -74,9 +74,9 @@ void ffPrintNetIO(FFNetIOOptions* options)
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&buffer2);
|
||||
ffParseSize(inf->rxBytes, &buffer);
|
||||
ffSizeAppendNum(inf->rxBytes, &buffer);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
ffParseSize(inf->txBytes, &buffer2);
|
||||
ffSizeAppendNum(inf->txBytes, &buffer2);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/temps.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/physicaldisk/physicaldisk.h"
|
||||
#include "modules/physicaldisk/physicaldisk.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -52,7 +52,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
|
||||
{
|
||||
formatKey(options, dev, result.length == 1 ? 0 : index + 1, &key);
|
||||
ffStrbufClear(&buffer);
|
||||
ffParseSize(dev->size, &buffer);
|
||||
ffSizeAppendNum(dev->size, &buffer);
|
||||
|
||||
const char* physicalType = dev->type & FF_PHYSICALDISK_TYPE_HDD
|
||||
? "HDD"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/physicalmemory/physicalmemory.h"
|
||||
#include "modules/physicalmemory/physicalmemory.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -32,7 +32,7 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
|
||||
{
|
||||
++i;
|
||||
ffStrbufClear(&prettySize);
|
||||
ffParseSize(device->size, &prettySize);
|
||||
ffSizeAppendNum(device->size, &prettySize);
|
||||
|
||||
if (options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/parsing.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/swap/swap.h"
|
||||
#include "modules/swap/swap.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -28,10 +28,10 @@ void printSwap(FFSwapOptions* options, uint8_t index, FFSwapResult* storage)
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(storage->bytesUsed, &usedPretty);
|
||||
ffSizeAppendNum(storage->bytesUsed, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(storage->bytesTotal, &totalPretty);
|
||||
ffSizeAppendNum(storage->bytesTotal, &totalPretty);
|
||||
|
||||
double percentage = storage->bytesTotal == 0
|
||||
? 0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "common/duration.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/time.h"
|
||||
@@ -23,7 +24,7 @@ void ffPrintUptime(FFUptimeOptions* options)
|
||||
{
|
||||
ffPrintLogoAndKey(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
ffParseDuration((uptime + 500) / 1000, &buffer);
|
||||
ffDurationAppendNum((uptime + 500) / 1000, &buffer);
|
||||
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,10 @@ void ffPrintWifi(FFWifiOptions* options)
|
||||
ffStrbufAppend(&buffer, &item->conn.protocol);
|
||||
}
|
||||
if (bandStr[0])
|
||||
ffStrbufAppendF(&buffer, " - %s GHz", bandStr);
|
||||
{
|
||||
ffStrbufAppendF(&buffer, " - %s%sGHz", bandStr,
|
||||
instance.config.display.freqSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_NEVER ? "" : " ");
|
||||
}
|
||||
if(item->conn.security.length)
|
||||
{
|
||||
ffStrbufAppendS(&buffer, " - ");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/percent.h"
|
||||
#include "common/size.h"
|
||||
#include "detection/zpool/zpool.h"
|
||||
#include "modules/zpool/zpool.h"
|
||||
#include "util/stringUtils.h"
|
||||
@@ -26,10 +27,10 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY usedPretty = ffStrbufCreate();
|
||||
ffParseSize(result->used, &usedPretty);
|
||||
ffSizeAppendNum(result->used, &usedPretty);
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY totalPretty = ffStrbufCreate();
|
||||
ffParseSize(result->total, &totalPretty);
|
||||
ffSizeAppendNum(result->total, &totalPretty);
|
||||
|
||||
double bytesPercentage = result->total > 0 ? (double) result->used / (double) result->total * 100.0 : 0;
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
|
||||
Reference in New Issue
Block a user