diff --git a/doc/json_schema.json b/doc/json_schema.json index f311c92cb..561213a08 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -17,6 +17,12 @@ "title": "Color of the module key. Left empty to use `display.color.keys`", "$ref": "#/$defs/colors" }, + "keyWidth": { + "title": "Width of the module key. Use 0 to use `display.keyWidth`", + "type": "integer", + "minimum": 0, + "default": 0 + }, "format": { "title": "Output format of the module", "type": "string" @@ -314,6 +320,12 @@ "type": "boolean", "default": true }, + "keyWidth": { + "title": "Align the width of keys to number of characters, 0 to disable", + "type": "integer", + "minimum": 0, + "default": 0 + }, "binaryPrefix": { "type": "string", "title": "Set the binary prefix to used when printing bytes", @@ -595,6 +607,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -622,6 +637,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -645,6 +663,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -668,6 +689,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -721,6 +745,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -741,6 +768,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "title": "Text to print", "type": "string" @@ -777,6 +807,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -819,6 +852,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -856,6 +892,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -908,6 +947,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -936,6 +978,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -966,6 +1011,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -1008,6 +1056,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -1049,6 +1100,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } @@ -1082,6 +1136,9 @@ "keyColor": { "$ref": "#/$defs/keyColor" }, + "keyWidth": { + "$ref": "#/$defs/keyWidth" + }, "format": { "$ref": "#/$defs/format" } diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 601d8b480..794b32405 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -17,14 +17,19 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* ffStrbufSetNS(&moduleArgs->key, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); return true; } + else if(ffStrEqualsIgnCase(key, "format")) + { + ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); + return true; + } else if(ffStrEqualsIgnCase(key, "keyColor")) { ffOptionParseColor(yyjson_get_str(val), &moduleArgs->keyColor); return true; } - else if(ffStrEqualsIgnCase(key, "format")) + else if(ffStrEqualsIgnCase(key, "keyWidth")) { - ffStrbufSetNS(&moduleArgs->outputFormat, (uint32_t) yyjson_get_len(val), yyjson_get_str(val)); + moduleArgs->keyWidth = (uint32_t) yyjson_get_uint(val); return true; } return false; @@ -521,5 +526,5 @@ void ffPrintJsonConfig(void) { const char* error = printJsonConfig(); if (error) - ffPrintErrorString("JsonConfig", 0, NULL, NULL, "%s", error); + ffPrintErrorString("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error); } diff --git a/src/common/option.c b/src/common/option.c index dc4be709d..cb72a385e 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -34,6 +34,11 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const ffOptionParseString(argumentKey, value, &result->key); return true; } + else if(ffStrEqualsIgnCase(subKey, "format")) + { + ffOptionParseString(argumentKey, value, &result->outputFormat); + return true; + } else if(ffStrEqualsIgnCase(subKey, "key-color")) { if(value == NULL) @@ -44,9 +49,9 @@ bool ffOptionParseModuleArgs(const char* argumentKey, const char* subKey, const ffOptionParseColor(value, &result->keyColor); return true; } - else if(ffStrEqualsIgnCase(subKey, "format")) + else if(ffStrEqualsIgnCase(subKey, "key-width")) { - ffOptionParseString(argumentKey, value, &result->outputFormat); + result->keyWidth = ffOptionParseUInt32(argumentKey, value); return true; } return false; @@ -175,6 +180,7 @@ void ffOptionInitModuleArg(FFModuleArgs* args) ffStrbufInit(&args->key); ffStrbufInit(&args->keyColor); ffStrbufInit(&args->outputFormat); + args->keyWidth = 0; } void ffOptionDestroyModuleArg(FFModuleArgs* args) diff --git a/src/common/option.h b/src/common/option.h index bbd956506..2ff3f0828 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -7,6 +7,7 @@ typedef struct FFModuleArgs FFstrbuf key; FFstrbuf keyColor; FFstrbuf outputFormat; + uint32_t keyWidth; } FFModuleArgs; typedef struct FFKeyValuePair diff --git a/src/common/printing.c b/src/common/printing.c index f62f50fa6..063127081 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -2,7 +2,7 @@ #include "common/printing.h" #include "util/textModifier.h" -void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor) +void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType) { ffLogoPrintLine(); @@ -16,14 +16,14 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb if (instance.config.brightColor) fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout); - if(customKeyColor != NULL && customKeyColor->length > 0) - ffPrintColor(customKeyColor); + if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0) + ffPrintColor(&moduleArgs->keyColor); else ffPrintColor(&instance.config.colorKeys); } //NULL check is required for modules with custom keys, e.g. disk with the folder path - if(customKeyFormat == NULL || customKeyFormat->length == 0) + if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0) { fputs(moduleName, stdout); @@ -33,7 +33,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb else { FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); - ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){ + ffParseFormatString(&key, &moduleArgs->key, 1, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex} }); ffStrbufWriteTo(&key, stdout); @@ -47,33 +47,36 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrb if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); - if (instance.config.keyWidth > 0) - printf("\e[%uG", (unsigned) (instance.config.keyWidth + instance.state.logoWidth)); + + if (!instance.config.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH)) + { + uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.keyWidth; + if (keyWidth > 0) + printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth)); + } } -void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments) +void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments) { - FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateA(256); - ffParseFormatString(&buffer, format, numArgs, arguments); + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + if (moduleArgs) + ffParseFormatString(&buffer, &moduleArgs->outputFormat, numArgs, arguments); + else + ffStrbufAppendS(&buffer, "unknown"); if(buffer.length > 0) { - ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor); + ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType); ffStrbufPutTo(&buffer, stdout); } } -void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) -{ - ffPrintFormatString(moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, &moduleArgs->outputFormat, numArgs, arguments); -} - -static void printError(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, va_list arguments) +static void printError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, va_list arguments) { if(!instance.config.showErrors) return; - ffPrintLogoAndKey(moduleName, moduleIndex, customKeyFormat, customKeyColor); + ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType); if(!instance.config.pipe) fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout); @@ -86,11 +89,11 @@ static void printError(const char* moduleName, uint8_t moduleIndex, const FFstrb putchar('\n'); } -void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...) +void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...) { va_list arguments; va_start(arguments, message); - printError(moduleName, moduleIndex, customKeyFormat, customKeyColor, message, arguments); + printError(moduleName, moduleIndex, moduleArgs, printType, message, arguments); va_end(arguments); } @@ -98,7 +101,7 @@ void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArg { va_list arguments; va_start(arguments, message); - printError(moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->keyColor, message, arguments); + printError(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, message, arguments); va_end(arguments); } diff --git a/src/common/printing.h b/src/common/printing.h index e25c0f82c..a03c55555 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -6,10 +6,21 @@ #include "fastfetch.h" #include "common/format.h" -void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor); -void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments); -void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments); -FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customKeyColor, const char* message, ...); +typedef enum FFPrintType { + FF_PRINT_TYPE_DEFAULT = 0, + FF_PRINT_TYPE_NO_CUSTOM_KEY = 1 << 0, + FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR = 1 << 1, + FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH = 1 << 2, + FF_PRINT_TYPE_NO_CUSTOM_OUTPUT_FORMAT = 1 << 3, // reserved +} FFPrintType; + +void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType); +void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments); +static inline void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments) +{ + ffPrintFormatString(moduleName, moduleIndex, moduleArgs, FF_PRINT_TYPE_DEFAULT, numArgs, arguments); +} +FF_C_PRINTF(5, 6) void ffPrintErrorString(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...); FF_C_PRINTF(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); diff --git a/src/data/help.txt b/src/data/help.txt index 95a74429c..4606bd48e 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -58,6 +58,7 @@ Display options: -s,--structure : Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available. --color-keys : Set the color of the keys --color-title : Set the color of the title + --key-width : Align the width of keys to characters --bright-color : Set if the keys, title and ASCII logo should be printed in bright color. Default is true -c,--color : Set the color of both the keys and title --separator : Set the separator between key and value. Default is a colon with a space @@ -82,6 +83,7 @@ General module options: For modules which print multiple lines, the string is parsed as a format string with the index as first character. ---key-color : Override the global `--color-keys` option for each specific module. + ---key-width : Override the global `--key-width` option for each specific module. Library options: Set the path of a library to load --lib-PCI diff --git a/src/fastfetch.c b/src/fastfetch.c index 58fd773e6..45375573e 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1389,7 +1389,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues) return ffPrintWMTheme(&instance.config.wmTheme); break; } - ffPrintErrorString(line, 0, NULL, NULL, ""); + ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, ""); } int main(int argc, const char** argv) diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 5f5a93329..eba6ba597 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -12,7 +12,7 @@ static void printBattery(FFBatteryOptions* options, BatteryResult* result, uint8 { if(instance.config.battery.moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); bool showStatus = !(instance.config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) && diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 398a7cc83..7aba0aef7 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -30,7 +30,7 @@ void ffPrintBios(FFBiosOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&bios.version, stdout); if (bios.release.length) printf(" (%s)", bios.release.chars); diff --git a/src/modules/bluetooth/bluetooth.c b/src/modules/bluetooth/bluetooth.c index bbd5e0e11..06bf1ce22 100644 --- a/src/modules/bluetooth/bluetooth.c +++ b/src/modules/bluetooth/bluetooth.c @@ -10,7 +10,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothDevice* de { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&device->name, stdout); if(device->battery > 0) diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 5c92ef20d..6ad125896 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -28,7 +28,7 @@ void ffPrintBoard(FFBoardOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result.name, stdout); if (result.version.length) printf(" (%s)", result.version.chars); diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 3e5ea3663..d5aa58b46 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -27,6 +27,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + uint32_t index = 0; FF_LIST_FOR_EACH(FFBrightnessResult, item, result) { if(options->moduleArgs.key.length == 0) @@ -35,7 +36,9 @@ void ffPrintBrightness(FFBrightnessOptions* options) } else { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ + uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; + ffParseFormatString(&key, &options->moduleArgs.key, 2, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->name} }); } @@ -44,7 +47,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); if (instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) { @@ -63,7 +66,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) } else { - ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_FLOAT, &item->value}, {FF_FORMAT_ARG_TYPE_STRBUF, &item->name}, }); @@ -71,6 +74,7 @@ void ffPrintBrightness(FFBrightnessOptions* options) ffStrbufClear(&key); ffStrbufDestroy(&item->name); + ++index; } } diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index e229748c8..53ee101ad 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -29,7 +29,7 @@ void ffPrintChassis(FFChassisOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result.type, stdout); if (result.version.length) printf(" (%s)", result.version.chars); diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index da559b5a3..0cceb28e8 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -122,7 +122,7 @@ void ffParseColorsJsonObject(yyjson_val* module) {}, }); if (error) - ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Invalid %s value: %s", key, error); + ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", key, error); else options.symbol = (FFColorsSymbol) value; continue; @@ -134,7 +134,7 @@ void ffParseColorsJsonObject(yyjson_val* module) continue; } - ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffPrintErrorString(FF_COLORS_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key); } } diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 7337e7553..c4390fc0d 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -30,7 +30,7 @@ void ffPrintCommand(FFCommandOptions* options) return; } - ffPrintLogoAndKey(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&result, stdout); } diff --git a/src/modules/cpu/cpu.c b/src/modules/cpu/cpu.c index 14d751685..fe4379243 100644 --- a/src/modules/cpu/cpu.c +++ b/src/modules/cpu/cpu.c @@ -30,7 +30,7 @@ void ffPrintCPU(FFCPUOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); diff --git a/src/modules/cpuusage/cpuusage.c b/src/modules/cpuusage/cpuusage.c index 32f24a462..bb8e015ee 100644 --- a/src/modules/cpuusage/cpuusage.c +++ b/src/modules/cpuusage/cpuusage.c @@ -21,7 +21,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT) diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 06a8d3d91..7a5602f5d 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -28,7 +28,7 @@ void ffPrintCursor(FFCursorOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result.theme, stdout); if(result.size.length > 0) diff --git a/src/modules/custom/custom.c b/src/modules/custom/custom.c index 105823651..b7b679241 100644 --- a/src/modules/custom/custom.c +++ b/src/modules/custom/custom.c @@ -12,7 +12,7 @@ void ffPrintCustom(FFCustomOptions* options) return; } - ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_CUSTOM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&options->moduleArgs.outputFormat, stdout); puts(FASTFETCH_TEXT_MODIFIER_RESET); } diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 12134c178..7d2cbd941 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -43,7 +43,7 @@ void ffPrintDateTime(FFDateTimeOptions* options) } const FFDateTimeResult* datetime = ffDetectDateTime(); - ffPrintLogoAndKey(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_DATETIME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); //yyyy-MM-dd HH:mm:ss printf("%u-%s-%02u %s:%s:%s\n", datetime->year, datetime->monthPretty.chars, datetime->dayInMonth, datetime->hourPretty.chars, datetime->minutePretty.chars, datetime->secondPretty.chars); diff --git a/src/modules/de/de.c b/src/modules/de/de.c index a32e6dc01..db3c775b5 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -18,7 +18,7 @@ void ffPrintDE(FFDEOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_DE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result->dePrettyName, stdout); diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index 8346f38a4..c7269a6d0 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -50,7 +50,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate(); @@ -96,7 +96,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk) bool isExternal = !!(disk->type & FF_DISK_TYPE_EXTERNAL_BIT); bool isHidden = !!(disk->type & FF_DISK_TYPE_HIDDEN_BIT); - ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty}, {FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty}, {FF_FORMAT_ARG_TYPE_UINT8, &bytesPercentage}, diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 848936f61..6b7980a62 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -18,7 +18,7 @@ void ffPrintDisplay(FFDisplayOptions* options) if (options->compactType != FF_DISPLAY_COMPACT_TYPE_NONE) { - ffPrintLogoAndKey(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_DISPLAY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); int index = 0; FF_LIST_FOR_EACH(FFDisplayResult, result, dsResult->displays) @@ -43,31 +43,32 @@ void ffPrintDisplay(FFDisplayOptions* options) for(uint32_t i = 0; i < dsResult->displays.length; i++) { FFDisplayResult* result = ffListGet(&dsResult->displays, i); - uint8_t moduleIndex = dsResult->displays.length == 1 ? 0 : (uint8_t) (i + 1); + uint32_t moduleIndex = dsResult->displays.length == 1 ? 0 : i + 1; const char* displayType = result->type == FF_DISPLAY_TYPE_UNKNOWN ? NULL : result->type == FF_DISPLAY_TYPE_BUILTIN ? "built-in" : "external"; + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) + { + const char* subkey = result->name.length ? result->name.chars : displayType; + if (subkey) + ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, subkey); + else if (moduleIndex > 0) + ffStrbufAppendF(&key, "%s (%d)", FF_DISPLAY_MODULE_NAME, moduleIndex); + else + ffStrbufAppendS(&key, FF_DISPLAY_MODULE_NAME); + } + else + { + ffParseFormatString(&key, &options->moduleArgs.key, 3, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex}, + {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, + {FF_FORMAT_ARG_TYPE_STRING, displayType}, + }); + } + if(options->moduleArgs.outputFormat.length == 0) { - ffStrbufClear(&key); - if(options->moduleArgs.key.length == 0) - { - const char* subkey = result->name.length ? result->name.chars : displayType; - if (subkey) - ffStrbufAppendF(&key, "%s (%s)", FF_DISPLAY_MODULE_NAME, subkey); - else if (moduleIndex > 0) - ffStrbufAppendF(&key, "%s (%d)", FF_DISPLAY_MODULE_NAME, moduleIndex); - else - ffStrbufAppendS(&key, FF_DISPLAY_MODULE_NAME); - } - else - { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_UINT, &i}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->name}, - {FF_FORMAT_ARG_TYPE_STRING, displayType}, - }); - } - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); printf("%ix%i", result->width, result->height); @@ -91,7 +92,7 @@ void ffPrintDisplay(FFDisplayOptions* options) } else { - ffPrintFormat(FF_DISPLAY_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_UINT, &result->width}, {FF_FORMAT_ARG_TYPE_UINT, &result->height}, {FF_FORMAT_ARG_TYPE_DOUBLE, &result->refreshRate}, diff --git a/src/modules/font/font.c b/src/modules/font/font.c index 9a8195cd0..8bc328cd3 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -23,7 +23,7 @@ void ffPrintFont(FFFontOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_FONT_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&font.display, stdout); } else diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index e5f28704c..18c417b3c 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -10,7 +10,7 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&device->name, stdout); } else diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 84a379f29..9f25e72e6 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -24,7 +24,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_GPU_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreateA(gpu->vendor.length + 1 + gpu->name.length); diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 53526f9ee..5c878134b 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -30,7 +30,7 @@ void ffPrintHost(FFHostOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_HOST_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index e1defe320..a79a97301 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -19,7 +19,7 @@ void ffPrintIcons(FFIconsOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&icons, stdout); } else diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index 8cef1ae06..e33233523 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -9,7 +9,7 @@ void ffPrintKernel(FFKernelOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&instance.state.platform.systemRelease, stdout); #ifdef _WIN32 diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index adaf7d094..c0608e8a0 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -28,7 +28,7 @@ void ffPrintLM(FFLMOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_LM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result.service, stdout); if(result.version.length) printf(" %s", result.version.chars); diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index 46b4377a4..21e5a3756 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -19,7 +19,7 @@ void ffPrintLocale(FFLocaleOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&locale, stdout); } else diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index d3aeb3cba..1b2772b01 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -13,7 +13,7 @@ static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right) return ffStrbufComp(&left->name, &right->name); } -static void formatKey(const FFLocalIpOptions* options, const FFLocalIpResult* ip, FFstrbuf* key) +static void formatKey(const FFLocalIpOptions* options, const FFLocalIpResult* ip, uint32_t index, FFstrbuf* key) { if(options->moduleArgs.key.length == 0) { @@ -25,8 +25,10 @@ static void formatKey(const FFLocalIpOptions* options, const FFLocalIpResult* ip else { ffStrbufClear(key); - ffParseFormatString(key, &options->moduleArgs.key, 2, (FFformatarg[]){ + ffParseFormatString(key, &options->moduleArgs.key, 3, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &index}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->name}, + {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, }); } } @@ -78,7 +80,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) if (options->showType & FF_LOCALIP_TYPE_COMPACT_BIT) { - ffPrintLogoAndKey(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_LOCALIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); bool flag = false; @@ -98,22 +100,23 @@ void ffPrintLocalIp(FFLocalIpOptions* options) else { FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + uint32_t index = 0; FF_LIST_FOR_EACH(FFLocalIpResult, ip, results) { if (options->defaultRouteOnly && !ip->defaultRoute) continue; - formatKey(options, ip, &key); + formatKey(options, ip, results.length == 1 ? 0 : index + 1, &key); if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); printIp(ip, !options->defaultRouteOnly); putchar('\n'); } else { - ffPrintFormatString(key.chars, 0, NULL, &options->moduleArgs.keyColor, &options->moduleArgs.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ + ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6}, {FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac}, @@ -121,6 +124,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options) {FF_FORMAT_ARG_TYPE_BOOL, &ip->defaultRoute}, }); } + ++index; } } diff --git a/src/modules/media/media.c b/src/modules/media/media.c index f28852e8c..f2969dd9a 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -80,7 +80,7 @@ void ffPrintMedia(FFMediaOptions* options) if(artistInSongTitle(&songPretty, &artistPretty)) ffStrbufClear(&artistPretty); - ffPrintLogoAndKey(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if(artistPretty.length > 0) { diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 8bd1e7e8f..7bc505c6e 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -31,7 +31,7 @@ void ffPrintMemory(FFMemoryOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if (storage.bytesTotal == 0) puts("Disabled"); else diff --git a/src/modules/monitor/monitor.c b/src/modules/monitor/monitor.c index 980223481..a267f393c 100644 --- a/src/modules/monitor/monitor.c +++ b/src/modules/monitor/monitor.c @@ -26,27 +26,30 @@ void ffPrintMonitor(FFMonitorOptions* options) return; } - uint8_t index = 0; FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + uint32_t index = 0; FF_LIST_FOR_EACH(FFMonitorResult, display, result) { double inch = sqrt(display->physicalWidth * display->physicalWidth + display->physicalHeight * display->physicalHeight) / 25.4; double ppi = sqrt(display->width * display->width + display->height * display->height) / inch; + ffStrbufClear(&key); + if(options->moduleArgs.key.length == 0) + { + ffStrbufAppendF(&key, "%s (%s)", FF_MONITOR_MODULE_NAME, display->name.chars); + } + else + { + uint32_t moduleIndex = result.length == 1 ? 0 : index + 1; + ffParseFormatString(&key, &options->moduleArgs.key, 2, (FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &moduleIndex}, + {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, + }); + } + if(options->moduleArgs.outputFormat.length == 0) { - ffStrbufClear(&key); - if(options->moduleArgs.key.length == 0) - { - ffStrbufAppendF(&key, "%s (%s)", FF_MONITOR_MODULE_NAME, display->name.chars); - } - else - { - ffParseFormatString(&key, &options->moduleArgs.key, 1, (FFformatarg[]){ - {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, - }); - } - ffPrintLogoAndKey(key.chars, 0, NULL, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY); printf("%ux%u px", display->width, display->height); if (inch > 0) @@ -56,7 +59,7 @@ void ffPrintMonitor(FFMonitorOptions* options) } else { - ffPrintFormat(FF_MONITOR_MODULE_NAME, index, &options->moduleArgs, FF_MONITOR_NUM_FORMAT_ARGS, (FFformatarg[]) { + ffPrintFormatString(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &display->name}, {FF_FORMAT_ARG_TYPE_UINT, &display->width}, {FF_FORMAT_ARG_TYPE_UINT, &display->height}, @@ -68,6 +71,7 @@ void ffPrintMonitor(FFMonitorOptions* options) } ffStrbufDestroy(&display->name); + ++index; } } diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index 3fd3ce1eb..daa4da00a 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -21,7 +21,7 @@ void ffPrintOpenCL(FFOpenCLOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&opencl.version, stdout); } else diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index e5f5bc9fc..e4d6ec008 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -23,7 +23,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); puts(result.version.chars); } else diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 119306742..299079c68 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -115,7 +115,7 @@ void ffPrintOS(FFOSOptions* options) else buildOutputDefault(os, &result); - ffPrintLogoAndKey(FF_OS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&result, stdout); } else diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 0fa86f31c..cb8c6ba2a 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -21,7 +21,7 @@ void ffPrintPackages(FFPackagesOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); #define FF_PRINT_PACKAGE_NAME(var, name) \ if(counts.var > 0) \ diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 1503a9cad..d78fc3f2f 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -59,7 +59,7 @@ void ffPrintPlayer(FFPlayerOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&playerPretty, stdout); } else diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 629a096b1..a5af37c03 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -32,7 +32,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if(result->name.length > 0) puts(result->name.chars); diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index bc5cf63b9..81b804124 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -19,7 +19,7 @@ void ffPrintProcesses(FFProcessesOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); printf("%u\n", numProcesses); } diff --git a/src/modules/publicip/publicip.c b/src/modules/publicip/publicip.c index 24d65ea3c..a5707e20e 100644 --- a/src/modules/publicip/publicip.c +++ b/src/modules/publicip/publicip.c @@ -62,7 +62,7 @@ void ffPrintPublicIp(FFPublicIpOptions* options) if (options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if (options->url.length == 0) { diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index a8d1d212c..74108fd3b 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -121,7 +121,7 @@ void ffParseSeparatorJsonObject(yyjson_val* module) continue; } - ffPrintErrorString(FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffPrintErrorString(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key); } } diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index efaca7441..00a305db7 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -18,7 +18,7 @@ void ffPrintShell(FFShellOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result->shellPrettyName, stdout); if(result->shellVersion.length > 0) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 2955c8f5b..d3e0e86dd 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -10,7 +10,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_SOUND_MODULE_NAME, index, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&device->name, stdout); if(device->volume != FF_SOUND_VOLUME_UNKNOWN) diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 5f13b286e..744e4ed9c 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -31,7 +31,7 @@ void ffPrintSwap(FFSwapOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if (storage.bytesTotal == 0) puts("Disabled"); else diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 315ede3bc..ed257fd52 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -20,7 +20,7 @@ void ffPrintTerminal(FFTerminalOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if(result->terminalVersion.length) printf("%s %s\n", result->terminalPrettyName.chars, result->terminalVersion.chars); diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 9e9b683d8..2c2886027 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -22,7 +22,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&terminalFont.font.pretty, stdout); if(terminalFont.fallback.pretty.length) { diff --git a/src/modules/terminalsize/terminalsize.c b/src/modules/terminalsize/terminalsize.c index e33966eb5..3a794cbfe 100644 --- a/src/modules/terminalsize/terminalsize.c +++ b/src/modules/terminalsize/terminalsize.c @@ -19,7 +19,7 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); printf("%u columns x %u rows", result.columns, result.rows); if (result.width != 0 && result.height != 0) diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 741e47c72..053c7cb57 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -19,7 +19,7 @@ void ffPrintTheme(FFThemeOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_THEME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&theme, stdout); } else diff --git a/src/modules/title/title.c b/src/modules/title/title.c index ef3d7abe4..297b0a6bb 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -29,7 +29,7 @@ void ffPrintTitle(FFTitleOptions* options) if (options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_TITLE_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(options->moduleArgs.key.length == 0 ? NULL : FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); printTitlePart(&instance.state.platform.userName, &options->colorUser); @@ -142,7 +142,7 @@ void ffParseTitleJsonObject(yyjson_val* module) continue; } - ffPrintErrorString(FF_TITLE_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); + ffPrintErrorString(FF_TITLE_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key); } } diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index f6a4bd424..3de7d80f7 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -25,7 +25,7 @@ void ffPrintUptime(FFUptimeOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if(days == 0 && hours == 0 && minutes == 0) { diff --git a/src/modules/users/users.c b/src/modules/users/users.c index ed18e7b14..260cd87d3 100644 --- a/src/modules/users/users.c +++ b/src/modules/users/users.c @@ -32,7 +32,7 @@ void ffPrintUsers(FFUsersOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_USERS_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_USERS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); puts(result.chars); } else diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index b4e51dfb9..aa79c6ddf 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -18,7 +18,7 @@ void ffPrintVulkan(FFVulkanOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if(vulkan->apiVersion.length > 0) { diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index 54785f6ca..08720f891 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -30,7 +30,7 @@ void ffPrintWallpaper(FFWallpaperOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); puts(filename); } else diff --git a/src/modules/weather/weather.c b/src/modules/weather/weather.c index b80875108..a32292f7d 100644 --- a/src/modules/weather/weather.c +++ b/src/modules/weather/weather.c @@ -42,7 +42,7 @@ void ffPrintWeather(FFWeatherOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufPutTo(&result, stdout); } else diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index cda777141..6798c063f 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -29,7 +29,7 @@ void ffPrintWifi(FFWifiOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); if(item->conn.ssid.length) { ffStrbufWriteTo(&item->conn.ssid, stdout); diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 6f60107ff..018bbee73 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -18,7 +18,7 @@ void ffPrintWM(FFWMOptions* options) if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_WM_MODULE_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result->wmPrettyName, stdout); diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index da66e8ad8..c61f216e6 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -14,7 +14,7 @@ void ffPrintWMTheme(FFWMThemeOptions* options) { if(options->moduleArgs.outputFormat.length == 0) { - ffPrintLogoAndKey(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs.key, &options->moduleArgs.keyColor); + ffPrintLogoAndKey(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); puts(themeOrError.chars); } else