Percentage: prepare to make threshold configurable

This commit is contained in:
李通洲
2024-01-20 14:10:13 +08:00
parent e7974a7cea
commit 62ca495155
22 changed files with 78 additions and 38 deletions
+3 -2
View File
@@ -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)
+2
View File
@@ -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;