diff --git a/src/common/percent.c b/src/common/percent.c index 0993346e8..98401121b 100644 --- a/src/common/percent.c +++ b/src/common/percent.c @@ -41,15 +41,18 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentageModuleConf } else { - const char* colorGreen = instance.config.display.percentColorGreen.chars; - const char* colorYellow = instance.config.display.percentColorYellow.chars; - const char* colorRed = instance.config.display.percentColorRed.chars; + const char* colorGreen = options->percentColorGreen.chars; + const char* colorYellow = options->percentColorYellow.chars; + const char* colorRed = options->percentColorRed.chars; + + FFPercentageTypeFlags percentType = config.type == 0 ? options->percentType : config.type; + bool monochrome = !!(percentType & FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT); for (uint32_t i = 0; i < blocksPercent; ++i) { if(!options->pipe) { - if (options->percentType & FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT) + if (monochrome) { const char* color = NULL; if (green <= yellow) @@ -110,8 +113,9 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentageModuleConf assert(green <= 100 && yellow <= 100); const FFOptionsDisplay* options = &instance.config.display; + FFPercentageTypeFlags percentType = config.type == 0 ? options->percentType : config.type; - bool colored = !!(options->percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT); + bool colored = !!(percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT); if (parentheses) ffStrbufAppendC(buffer, '('); @@ -187,6 +191,12 @@ bool ffPercentParseCommandOptions(const char* key, const char* subkey, const cha return true; } + if (ffStrEqualsIgnCase(subkey, "type")) + { + config->type = (FFPercentageTypeFlags) ffOptionParseUInt32(key, value); + return true; + } + return false; } @@ -225,6 +235,12 @@ bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentageMo config->yellow = (uint8_t) num; } + yyjson_val* typeVal = yyjson_obj_get(value, "type"); + if (typeVal) + { + config->type = (FFPercentageTypeFlags) yyjson_get_int(typeVal); + } + return true; } @@ -238,4 +254,6 @@ void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FF yyjson_mut_obj_add_uint(doc, percent, "green", config.green); if (config.yellow != defaultConfig.yellow) yyjson_mut_obj_add_uint(doc, percent, "yellow", config.yellow); + if (config.type != defaultConfig.type) + yyjson_mut_obj_add_uint(doc, percent, "type", config.type); } diff --git a/src/common/percent.h b/src/common/percent.h index c7350ff1c..f06ad1a3e 100644 --- a/src/common/percent.h +++ b/src/common/percent.h @@ -20,6 +20,7 @@ typedef struct FFPercentageModuleConfig { uint8_t green; uint8_t yellow; + FFPercentageTypeFlags type; } FFPercentageModuleConfig; // if (green <= yellow) diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index fad309bb7..013b9a695 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -39,24 +39,26 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin timeRemaining /= 24; uint32_t days = timeRemaining; + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; + if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); bool showStatus = - !(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && + !(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && result->status.length > 0 && ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0; if(result->capacity >= 0) { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&str, result->capacity, options->percent, &options->moduleArgs); } - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if(str.length > 0) ffStrbufAppendC(&str, ' '); @@ -301,7 +303,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options) ffOptionInitModuleArg(&options->moduleArgs, ""); options->temp = false; options->tempConfig = (FFColorRangeConfig) { 60, 80 }; - options->percent = (FFPercentageModuleConfig) { 50, 20 }; + options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; #ifdef _WIN32 options->useSetupApi = false; diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index 0139289e1..bd07ab0d3 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -13,9 +13,20 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de { ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); - FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateCopy(&device->name); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + bool showBatteryLevel = device->battery > 0 && device->battery <= 100; + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; - if (device->battery > 0 && device->battery <= 100) + if (showBatteryLevel && (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)) + { + ffPercentAppendBar(&buffer, device->battery, options->percent, &options->moduleArgs); + ffStrbufAppendC(&buffer, ' '); + } + + if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + ffStrbufAppend(&buffer, &device->name); + + if (showBatteryLevel && (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)) { if (buffer.length) ffStrbufAppendC(&buffer, ' '); @@ -202,7 +213,7 @@ void ffInitBluetoothOptions(FFBluetoothOptions* options) ); ffOptionInitModuleArg(&options->moduleArgs, ""); options->showDisconnected = false; - options->percent = (FFPercentageModuleConfig) { 50, 20 }; + options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; } void ffDestroyBluetoothOptions(FFBluetoothOptions* options) diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 7b06613c5..bc06b68ba 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -25,6 +25,8 @@ void ffPrintBrightness(FFBrightnessOptions* options) return; } + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; + if (options->compact) { FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); @@ -48,7 +50,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) uint32_t index = 0; FF_LIST_FOR_EACH(FFBrightnessResult, item, result) { - if(options->moduleArgs.key.length == 0) + if (options->moduleArgs.key.length == 0) { ffStrbufAppendF(&key, "%s (%s)", FF_BRIGHTNESS_MODULE_NAME, item->name.chars); } @@ -64,17 +66,17 @@ void ffPrintBrightness(FFBrightnessOptions* options) const double percent = (item->current - item->min) / (item->max - item->min) * 100; - if(options->moduleArgs.outputFormat.length == 0) + if (options->moduleArgs.outputFormat.length == 0) { FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); - if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&str, percent, options->percent, &options->moduleArgs); } - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if(str.length > 0) ffStrbufAppendC(&str, ' '); @@ -237,7 +239,7 @@ void ffInitBrightnessOptions(FFBrightnessOptions* options) ffOptionInitModuleArg(&options->moduleArgs, "󰯪"); options->ddcciSleep = 10; - options->percent = (FFPercentageModuleConfig) { 100, 100 }; + options->percent = (FFPercentageModuleConfig) { 100, 100, 0 }; options->compact = false; } diff --git a/src/modules/btrfs/btrfs.c b/src/modules/btrfs/btrfs.c index c874b69d4..7054e8139 100644 --- a/src/modules/btrfs/btrfs.c +++ b/src/modules/btrfs/btrfs.c @@ -245,7 +245,7 @@ void ffInitBtrfsOptions(FFBtrfsOptions* options) ffGenerateBtrfsJsonConfig ); ffOptionInitModuleArg(&options->moduleArgs, "󱑛"); - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } void ffDestroyBtrfsOptions(FFBtrfsOptions* options) diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index cf4a5a65c..1fc7490c6 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -44,6 +44,8 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options) } double avgValue = sumValue / (double) valueCount; + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; + if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); @@ -51,9 +53,9 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options) FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if (!options->separate) { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&str, avgValue, options->percent, &options->moduleArgs); - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if(str.length > 0) ffStrbufAppendC(&str, ' '); @@ -214,7 +216,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options) ); ffOptionInitModuleArg(&options->moduleArgs, "󰓅"); options->separate = false; - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; options->waitTime = 200; } diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 2eb39f48f..b47c2bb0a 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -51,6 +51,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index ffParseSize(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; if(options->moduleArgs.outputFormat.length == 0) { @@ -60,16 +61,16 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index if(disk->bytesTotal > 0) { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&str, bytesPercentage, options->percent, &options->moduleArgs); ffStrbufAppendC(&str, ' '); } - if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { ffPercentAppendNum(&str, bytesPercentage, options->percent, str.length > 0, &options->moduleArgs); ffStrbufAppendC(&str, ' '); @@ -78,7 +79,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index else ffStrbufAppendS(&str, "Unknown "); - if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) { if(disk->filesystem.length) ffStrbufAppendF(&str, "- %s ", disk->filesystem.chars); @@ -473,7 +474,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 = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } void ffDestroyDiskOptions(FFDiskOptions* options) diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index f30aa1772..154b71a6e 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -13,9 +13,20 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device { ffPrintLogoAndKey(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); - FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateCopy(&device->name); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + bool showBatteryLevel = device->battery > 0 && device->battery <= 100; + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; - if (device->battery > 0 && device->battery <= 100) + if (showBatteryLevel && (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)) + { + ffPercentAppendBar(&buffer, device->battery, options->percent, &options->moduleArgs); + ffStrbufAppendC(&buffer, ' '); + } + + if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + ffStrbufAppend(&buffer, &device->name); + + if (showBatteryLevel && (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)) { if (buffer.length) ffStrbufAppendC(&buffer, ' '); @@ -160,7 +171,7 @@ void ffInitGamepadOptions(FFGamepadOptions* options) ffGenerateGamepadJsonConfig ); ffOptionInitModuleArg(&options->moduleArgs, "󰺵"); - options->percent = (FFPercentageModuleConfig) { 50, 20 }; + options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; } void ffDestroyGamepadOptions(FFGamepadOptions* options) diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 890e06716..3489fc57e 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -439,7 +439,7 @@ void ffInitGPUOptions(FFGPUOptions* options) options->temp = false; options->hideType = FF_GPU_TYPE_UNKNOWN; options->tempConfig = (FFColorRangeConfig) { 60, 80 }; - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } void ffDestroyGPUOptions(FFGPUOptions* options) diff --git a/src/modules/loadavg/loadavg.c b/src/modules/loadavg/loadavg.c index 4e712e93b..27e74a98e 100644 --- a/src/modules/loadavg/loadavg.c +++ b/src/modules/loadavg/loadavg.c @@ -59,18 +59,19 @@ void ffPrintLoadavg(FFLoadavgOptions* options) ffStrbufClear(&buffer); double percent = result[index] * 100 / cpu.coresOnline; + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; - if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) ffPercentAppendBar(&buffer, percent, options->percent, &options->moduleArgs); - if (!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) { if (buffer.length > 0) ffStrbufAppendC(&buffer, ' '); ffStrbufAppendF(&buffer, "%.*f", options->ndigits, result[index]); } - if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if (buffer.length > 0) ffStrbufAppendC(&buffer, ' '); @@ -204,7 +205,7 @@ void ffInitLoadavgOptions(FFLoadavgOptions* options) ); ffOptionInitModuleArg(&options->moduleArgs, ""); - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; options->ndigits = 2; options->compact = true; } diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 58b0aff7f..d364225c1 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -37,17 +37,18 @@ void ffPrintMemory(FFMemoryOptions* options) else { FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&str, percentage, options->percent, &options->moduleArgs); ffStrbufAppendC(&str, ' '); } - if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT) ffPercentAppendNum(&str, percentage, options->percent, str.length > 0, &options->moduleArgs); ffStrbufTrimRight(&str, ' '); @@ -152,7 +153,7 @@ void ffInitMemoryOptions(FFMemoryOptions* options) ffGenerateMemoryJsonConfig ); ffOptionInitModuleArg(&options->moduleArgs, ""); - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } void ffDestroyMemoryOptions(FFMemoryOptions* options) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index ad78fa320..dafc37619 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -12,14 +12,15 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); - if (!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppend(&str, &device->name); if(device->volume != FF_SOUND_VOLUME_UNKNOWN) { - if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { if (str.length) ffStrbufAppendC(&str, ' '); @@ -27,7 +28,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui ffPercentAppendBar(&str, device->volume, options->percent, &options->moduleArgs); } - if (instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { if (str.length) ffStrbufAppendC(&str, ' '); @@ -36,7 +37,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui } } - if (!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) { if (device->main && index > 0) ffStrbufAppendS(&str, " (*)"); @@ -253,7 +254,7 @@ void ffInitSoundOptions(FFSoundOptions* options) ffOptionInitModuleArg(&options->moduleArgs, ""); options->soundType = FF_SOUND_TYPE_MAIN; - options->percent = (FFPercentageModuleConfig) { 80, 90 }; + options->percent = (FFPercentageModuleConfig) { 80, 90, 0 }; } void ffDestroySoundOptions(FFSoundOptions* options) diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 235e7b9f7..c71831571 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -33,30 +33,32 @@ void ffPrintSwap(FFSwapOptions* options) { ffPrintLogoAndKey(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; + if (storage.bytesTotal == 0) { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&str, 0, options->percent, &options->moduleArgs); ffStrbufAppendC(&str, ' '); } - if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendS(&str, "Disabled"); else ffPercentAppendNum(&str, 0, options->percent, str.length > 0, &options->moduleArgs); } else { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&str, percentage, options->percent, &options->moduleArgs); ffStrbufAppendC(&str, ' '); } - if(!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if(!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT) ffPercentAppendNum(&str, percentage, options->percent, str.length > 0, &options->moduleArgs); } @@ -161,7 +163,7 @@ void ffInitSwapOptions(FFSwapOptions* options) ffGenerateSwapJsonConfig ); ffOptionInitModuleArg(&options->moduleArgs, "󰓡"); - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } void ffDestroySwapOptions(FFSwapOptions* options) diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index a65de1168..be6b63649 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -22,6 +22,8 @@ void ffPrintWifi(FFWifiOptions* options) return; } + FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type; + for(uint32_t index = 0; index < result.length; ++index) { FFWifiResult* item = FF_LIST_GET(FFWifiResult, result, index); @@ -36,14 +38,14 @@ void ffPrintWifi(FFWifiOptions* options) { if(item->conn.signalQuality == item->conn.signalQuality) { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { ffPercentAppendBar(&buffer, item->conn.signalQuality, options->percent, &options->moduleArgs); ffStrbufAppendC(&buffer, ' '); } } - if (!(instance.config.display.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) + if (!(percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT)) { ffStrbufAppend(&buffer, &item->conn.ssid); @@ -62,7 +64,7 @@ void ffPrintWifi(FFWifiOptions* options) if(item->conn.signalQuality == item->conn.signalQuality) { - if(instance.config.display.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT) ffPercentAppendNum(&buffer, item->conn.signalQuality, options->percent, buffer.length > 0, &options->moduleArgs); } @@ -222,7 +224,7 @@ void ffInitWifiOptions(FFWifiOptions* options) ); ffOptionInitModuleArg(&options->moduleArgs, ""); - options->percent = (FFPercentageModuleConfig) { 50, 20 }; + options->percent = (FFPercentageModuleConfig) { 50, 20, 0 }; } void ffDestroyWifiOptions(FFWifiOptions* options) diff --git a/src/modules/zpool/zpool.c b/src/modules/zpool/zpool.c index 41cec9a23..a8e56146f 100644 --- a/src/modules/zpool/zpool.c +++ b/src/modules/zpool/zpool.c @@ -205,7 +205,7 @@ void ffInitZpoolOptions(FFZpoolOptions* options) ffGenerateZpoolJsonConfig ); ffOptionInitModuleArg(&options->moduleArgs, "󱑛"); - options->percent = (FFPercentageModuleConfig) { 50, 80 }; + options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } void ffDestroyZpoolOptions(FFZpoolOptions* options)