mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Percentage: prepare to make threshold configurable
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
#include "common/color.h"
|
||||
#include "util/textModifier.h"
|
||||
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow)
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config)
|
||||
{
|
||||
uint8_t green = config.green, yellow = config.yellow;
|
||||
assert(green <= 100 && yellow <= 100);
|
||||
|
||||
const FFOptionsDisplay* options = &instance.config.display;
|
||||
@@ -56,8 +57,9 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
}
|
||||
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses)
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses)
|
||||
{
|
||||
uint8_t green = config.green, yellow = config.yellow;
|
||||
assert(green <= 100 && yellow <= 100);
|
||||
|
||||
const FFOptionsDisplay* options = &instance.config.display;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
#include "util/FFstrbuf.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -10,6 +10,12 @@ enum
|
||||
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
|
||||
};
|
||||
|
||||
typedef struct FFPercentConfig
|
||||
{
|
||||
uint8_t green;
|
||||
uint8_t yellow;
|
||||
} FFPercentConfig;
|
||||
|
||||
// if (green <= yellow)
|
||||
// [0, green]: print green
|
||||
// (green, yellow]: print yellow
|
||||
@@ -20,5 +26,5 @@ enum
|
||||
// [yellow, green): print yellow
|
||||
// [0, yellow): print red
|
||||
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow);
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses);
|
||||
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config);
|
||||
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses);
|
||||
|
||||
@@ -24,7 +24,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, result->capacity, 50, 20);
|
||||
ffPercentAppendBar(&str, result->capacity, options->percent);
|
||||
}
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -32,7 +32,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffPercentAppendNum(&str, result->capacity, 50, 20, str.length > 0);
|
||||
ffPercentAppendNum(&str, result->capacity, options->percent, str.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY capacityStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&capacityStr, result->capacity, 51, 21, false);
|
||||
ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false);
|
||||
ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
|
||||
@@ -240,6 +240,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options)
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->temp = false;
|
||||
options->percent = (FFPercentConfig) { 50, 20 };
|
||||
|
||||
#ifdef _WIN32
|
||||
options->useSetupApi = false;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFBatteryOptions
|
||||
{
|
||||
@@ -10,6 +11,7 @@ typedef struct FFBatteryOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
bool temp;
|
||||
FFPercentConfig percent;
|
||||
|
||||
#ifdef _WIN32
|
||||
bool useSetupApi;
|
||||
|
||||
@@ -19,7 +19,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
{
|
||||
if (buffer.length)
|
||||
ffStrbufAppendC(&buffer, ' ');
|
||||
ffPercentAppendNum(&buffer, device->battery, 50, 20, buffer.length > 0);
|
||||
ffPercentAppendNum(&buffer, device->battery, options->percent, buffer.length > 0);
|
||||
}
|
||||
|
||||
if (!device->connected)
|
||||
@@ -28,7 +28,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, device->battery, 50, 20, false);
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false);
|
||||
|
||||
ffPrintFormat(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_BLUETOOTH_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
@@ -188,6 +188,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options)
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->showDisconnected = false;
|
||||
options->percent = (FFPercentConfig) { 50, 20 };
|
||||
}
|
||||
|
||||
void ffDestroyBluetoothOptions(FFBluetoothOptions* options)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFBluetoothOptions
|
||||
{
|
||||
@@ -10,4 +11,5 @@ typedef struct FFBluetoothOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
bool showDisconnected;
|
||||
FFPercentConfig percent;
|
||||
} FFBluetoothOptions;
|
||||
|
||||
@@ -52,7 +52,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
|
||||
if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, percent, 100, 100);
|
||||
ffPercentAppendBar(&str, percent, options->percent);
|
||||
}
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -60,7 +60,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffPercentAppendNum(&str, percent, 100, 100, str.length > 0);
|
||||
ffPercentAppendNum(&str, percent, options->percent, str.length > 0);
|
||||
}
|
||||
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -68,7 +68,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&valueStr, percent, 10, 10, false);
|
||||
ffPercentAppendNum(&valueStr, percent, options->percent, false);
|
||||
ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name},
|
||||
@@ -197,6 +197,7 @@ void ffInitBrightnessOptions(FFBrightnessOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
options->ddcciSleep = 10;
|
||||
options->percent = (FFPercentConfig) { 100, 100 };
|
||||
}
|
||||
|
||||
void ffDestroyBrightnessOptions(FFBrightnessOptions* options)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFBrightnessOptions
|
||||
{
|
||||
@@ -10,4 +11,5 @@ typedef struct FFBrightnessOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
uint32_t ddcciSleep; // ms
|
||||
FFPercentConfig percent;
|
||||
} FFBrightnessOptions;
|
||||
|
||||
@@ -52,12 +52,12 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
if (!options->separate)
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&str, avgValue, 50, 80);
|
||||
ffPercentAppendBar(&str, avgValue, options->percent);
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffPercentAppendNum(&str, avgValue, 50, 80, str.length > 0);
|
||||
ffPercentAppendNum(&str, avgValue, options->percent, str.length > 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -66,7 +66,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
{
|
||||
if(str.length > 0)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
ffPercentAppendNum(&str, *percent, 50, 80, false);
|
||||
ffPercentAppendNum(&str, *percent, options->percent, false);
|
||||
}
|
||||
}
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -74,11 +74,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY avgStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&avgStr, avgValue, 50, 80, false);
|
||||
ffPercentAppendNum(&avgStr, avgValue, options->percent, false);
|
||||
FF_STRBUF_AUTO_DESTROY minStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&minStr, minValue, 50, 80, false);
|
||||
ffPercentAppendNum(&minStr, minValue, options->percent, false);
|
||||
FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&maxStr, maxValue, 50, 80, false);
|
||||
ffPercentAppendNum(&maxStr, maxValue, options->percent, false);
|
||||
ffPrintFormat(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_CPUUSAGE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &avgStr},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &maxStr},
|
||||
@@ -182,6 +182,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->separate = false;
|
||||
options->percent = (FFPercentConfig) { 50, 80 };
|
||||
}
|
||||
|
||||
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFCPUUsageOptions
|
||||
{
|
||||
@@ -10,4 +11,5 @@ typedef struct FFCPUUsageOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
bool separate;
|
||||
FFPercentConfig percent;
|
||||
} FFCPUUsageOptions;
|
||||
|
||||
@@ -59,7 +59,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, bytesPercentage, 50, 80);
|
||||
ffPercentAppendBar(&str, bytesPercentage, options->percent);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
{
|
||||
ffPercentAppendNum(&str, bytesPercentage, 50, 80, str.length > 0);
|
||||
ffPercentAppendNum(&str, bytesPercentage, options->percent, str.length > 0);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
}
|
||||
@@ -104,10 +104,10 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY bytesPercentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&bytesPercentageStr, bytesPercentage, 50, 80, false);
|
||||
ffPercentAppendNum(&bytesPercentageStr, bytesPercentage, options->percent, false);
|
||||
FF_STRBUF_AUTO_DESTROY filesPercentageStr = ffStrbufCreate();
|
||||
double filesPercentage = disk->filesTotal > 0 ? ((double) disk->filesUsed / (double) disk->filesTotal) * 100.0 : 0;
|
||||
ffPercentAppendNum(&filesPercentageStr, filesPercentage, 50, 80, false);
|
||||
ffPercentAppendNum(&filesPercentageStr, filesPercentage, options->percent, false);
|
||||
|
||||
bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
|
||||
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
|
||||
@@ -476,6 +476,7 @@ void ffInitDiskOptions(FFDiskOptions* options)
|
||||
ffStrbufInit(&options->folders);
|
||||
options->showTypes = FF_DISK_VOLUME_TYPE_REGULAR_BIT | FF_DISK_VOLUME_TYPE_EXTERNAL_BIT | FF_DISK_VOLUME_TYPE_READONLY_BIT;
|
||||
options->calcType = FF_DISK_CALC_TYPE_FREE;
|
||||
options->percent = (FFPercentConfig) { 50, 80 };
|
||||
}
|
||||
|
||||
void ffDestroyDiskOptions(FFDiskOptions* options)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef enum FFDiskVolumeType
|
||||
{
|
||||
@@ -29,4 +30,5 @@ typedef struct FFDiskOptions
|
||||
FFstrbuf folders;
|
||||
FFDiskVolumeType showTypes;
|
||||
FFDiskCalcType calcType;
|
||||
FFPercentConfig percent;
|
||||
} FFDiskOptions;
|
||||
|
||||
@@ -19,14 +19,14 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
|
||||
{
|
||||
if (buffer.length)
|
||||
ffStrbufAppendC(&buffer, ' ');
|
||||
ffPercentAppendNum(&buffer, device->battery, 50, 20, buffer.length > 0);
|
||||
ffPercentAppendNum(&buffer, device->battery, options->percent, buffer.length > 0);
|
||||
}
|
||||
ffStrbufPutTo(&buffer, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, device->battery, 50, 20, false);
|
||||
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false);
|
||||
|
||||
ffPrintFormat(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
@@ -133,7 +133,7 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs
|
||||
|
||||
void ffPrintGamepadHelpFormat(void)
|
||||
{
|
||||
ffPrintModuleFormatHelp(FF_GAMEPAD_MODULE_NAME, "{1}", FF_GAMEPAD_NUM_FORMAT_ARGS, (const char* []) {
|
||||
ffPrintModuleFormatHelp(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, (const char* []) {
|
||||
"Name",
|
||||
"Serial number",
|
||||
"Battery percentage",
|
||||
@@ -154,6 +154,7 @@ void ffInitGamepadOptions(FFGamepadOptions* options)
|
||||
ffGenerateGamepadJsonConfig
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->percent = (FFPercentConfig) { 50, 20 };
|
||||
}
|
||||
|
||||
void ffDestroyGamepadOptions(FFGamepadOptions* options)
|
||||
|
||||
@@ -8,4 +8,6 @@ typedef struct FFGamepadOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFPercentConfig percent;
|
||||
} FFGamepadOptions;
|
||||
|
||||
@@ -60,7 +60,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
if(gpu->dedicated.used != FF_GPU_VMEM_SIZE_UNSET)
|
||||
{
|
||||
ffStrbufAppendS(&output, ", ");
|
||||
ffPercentAppendNum(&output, (double) gpu->dedicated.used / (double) gpu->dedicated.total * 100.0, 50, 80, false);
|
||||
ffPercentAppendNum(&output, (double) gpu->dedicated.used / (double) gpu->dedicated.total * 100.0, options->percent, false);
|
||||
}
|
||||
ffStrbufAppendC(&output, ')');
|
||||
}
|
||||
@@ -363,6 +363,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
|
||||
options->forceVulkan = false;
|
||||
options->temp = false;
|
||||
options->hideType = FF_GPU_TYPE_UNKNOWN;
|
||||
options->percent = (FFPercentConfig) { 50, 80 };
|
||||
}
|
||||
|
||||
void ffDestroyGPUOptions(FFGPUOptions* options)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef enum FFGPUType
|
||||
{
|
||||
@@ -20,4 +21,5 @@ typedef struct FFGPUOptions
|
||||
bool temp;
|
||||
bool driverSpecific;
|
||||
bool forceVulkan;
|
||||
FFPercentConfig percent;
|
||||
} FFGPUOptions;
|
||||
|
||||
@@ -40,7 +40,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, percentage, 50, 80);
|
||||
ffPercentAppendBar(&str, percentage, options->percent);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffPercentAppendNum(&str, percentage, 50, 80, str.length > 0);
|
||||
ffPercentAppendNum(&str, percentage, options->percent, str.length > 0);
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
ffStrbufPutTo(&str, stdout);
|
||||
@@ -57,7 +57,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, percentage, 50, 80, false);
|
||||
ffPercentAppendNum(&percentageStr, percentage, options->percent, false);
|
||||
ffPrintFormat(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_MEMORY_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
@@ -140,6 +140,7 @@ void ffInitMemoryOptions(FFMemoryOptions* options)
|
||||
ffGenerateMemoryJsonConfig
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->percent = (FFPercentConfig) { 50, 80 };
|
||||
}
|
||||
|
||||
void ffDestroyMemoryOptions(FFMemoryOptions* options)
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFMemoryOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFPercentConfig percent;
|
||||
} FFMemoryOptions;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef enum FFSoundType
|
||||
{
|
||||
@@ -17,4 +18,5 @@ typedef struct FFSoundOptions
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFSoundType soundType;
|
||||
FFPercentConfig percent;
|
||||
} FFSoundOptions;
|
||||
|
||||
@@ -24,7 +24,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
|
||||
if (str.length)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffPercentAppendBar(&str, device->volume, 80, 90);
|
||||
ffPercentAppendBar(&str, device->volume, options->percent);
|
||||
}
|
||||
|
||||
if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
@@ -32,7 +32,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
|
||||
if (str.length)
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
|
||||
ffPercentAppendNum(&str, device->volume, 80, 90, str.length > 0);
|
||||
ffPercentAppendNum(&str, device->volume, options->percent, str.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, device->volume, 80, 90, false);
|
||||
ffPercentAppendNum(&percentageStr, device->volume, options->percent, false);
|
||||
|
||||
ffPrintFormat(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_SOUND_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_BOOL, &device->main},
|
||||
@@ -247,6 +247,7 @@ void ffInitSoundOptions(FFSoundOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
options->soundType = FF_SOUND_TYPE_MAIN;
|
||||
options->percent = (FFPercentConfig) { 80, 90 };
|
||||
}
|
||||
|
||||
void ffDestroySoundOptions(FFSoundOptions* options)
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
// This file will be included in "fastfetch.h", do NOT put unnecessary things here
|
||||
|
||||
#include "common/option.h"
|
||||
#include "common/percent.h"
|
||||
|
||||
typedef struct FFSwapOptions
|
||||
{
|
||||
FFModuleBaseInfo moduleInfo;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
FFPercentConfig percent;
|
||||
} FFSwapOptions;
|
||||
|
||||
@@ -37,19 +37,19 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, 0, 50, 80);
|
||||
ffPercentAppendBar(&str, 0, options->percent);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
|
||||
ffStrbufAppendS(&str, "Disabled");
|
||||
else
|
||||
ffPercentAppendNum(&str, 0, 50, 80, str.length > 0);
|
||||
ffPercentAppendNum(&str, 0, options->percent, str.length > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
{
|
||||
ffPercentAppendBar(&str, percentage, 50, 80);
|
||||
ffPercentAppendBar(&str, percentage, options->percent);
|
||||
ffStrbufAppendC(&str, ' ');
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
|
||||
|
||||
if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
|
||||
ffPercentAppendNum(&str, percentage, 50, 80, str.length > 0);
|
||||
ffPercentAppendNum(&str, percentage, options->percent, str.length > 0);
|
||||
}
|
||||
|
||||
ffStrbufTrimRight(&str, ' ');
|
||||
@@ -66,7 +66,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
|
||||
ffPercentAppendNum(&percentageStr, percentage, 50, 80, false);
|
||||
ffPercentAppendNum(&percentageStr, percentage, options->percent, false);
|
||||
ffPrintFormat(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_SWAP_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty},
|
||||
@@ -149,6 +149,7 @@ void ffInitSwapOptions(FFSwapOptions* options)
|
||||
ffGenerateSwapJsonConfig
|
||||
);
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
options->percent = (FFPercentConfig) { 50, 80 };
|
||||
}
|
||||
|
||||
void ffDestroySwapOptions(FFSwapOptions* options)
|
||||
|
||||
Reference in New Issue
Block a user