mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Global: support --module-key-width per module
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+8
-2
@@ -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)
|
||||
|
||||
@@ -7,6 +7,7 @@ typedef struct FFModuleArgs
|
||||
FFstrbuf key;
|
||||
FFstrbuf keyColor;
|
||||
FFstrbuf outputFormat;
|
||||
uint32_t keyWidth;
|
||||
} FFModuleArgs;
|
||||
|
||||
typedef struct FFKeyValuePair
|
||||
|
||||
+24
-21
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+15
-4
@@ -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);
|
||||
|
||||
@@ -58,6 +58,7 @@ Display options:
|
||||
-s,--structure <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 <color>: Set the color of the keys
|
||||
--color-title <color>: Set the color of the title
|
||||
--key-width <num>: Align the width of keys to <num> characters
|
||||
--bright-color <?value>: Set if the keys, title and ASCII logo should be printed in bright color. Default is true
|
||||
-c,--color <color>: Set the color of both the keys and title
|
||||
--separator <str>: 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.
|
||||
|
||||
--<module>-key-color <format>: Override the global `--color-keys` option for each specific module.
|
||||
--<module>-key-width <num>: Override the global `--key-width` option for each specific module.
|
||||
|
||||
Library options: Set the path of a library to load
|
||||
--lib-PCI <path>
|
||||
|
||||
+1
-1
@@ -1389,7 +1389,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues)
|
||||
return ffPrintWMTheme(&instance.config.wmTheme);
|
||||
break;
|
||||
}
|
||||
ffPrintErrorString(line, 0, NULL, NULL, "<no implementation provided>");
|
||||
ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>");
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
|
||||
@@ -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) &&
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user