diff --git a/CHANGELOG.md b/CHANGELOG.md index 80dc9de96..7657821e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,15 @@ # 2.8.6 Changes: -* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temperature": { "unit": "C" } }` +* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temp": { "unit": "C" } }` Bugfixes: * Fix incorrect GPU name detection for Intel iGPU on Linux (#736, GPU, Linux) Features: * Support additional temperature formatting options (#737) - * `{ "temperature": { "ndigits": 1 } }` - * `{ "temperature": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }` + * `{ "temp": { "ndigits": 1 } }` + * `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }` # 2.8.5 diff --git a/doc/json_schema.json b/doc/json_schema.json index ff1750196..73c8adce1 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -59,13 +59,13 @@ "type": "integer", "minimum": 0, "maximum": 100, - "description": "Value less then green will be shown in green" + "description": "Value (in celsius) less then green will be shown in green" }, "yellow": { "type": "integer", "minimum": 0, "maximum": 100, - "description": "Value greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red" + "description": "Value (in celsius) greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red" } } } @@ -433,9 +433,9 @@ } } }, - "temperature": { + "temp": { "type": "object", - "description": "Set how a temperature value should be displayed", + "description": "Set how temperature values should be displayed", "properties": { "unit": { "type": "string", diff --git a/src/common/temps.c b/src/common/temps.c index b46abad79..d72f46f0e 100644 --- a/src/common/temps.c +++ b/src/common/temps.c @@ -9,9 +9,9 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi return; const FFOptionsDisplay* options = &instance.config.display; - const char* colorGreen = options->temperatureColorGreen.chars; - const char* colorYellow = options->temperatureColorYellow.chars; - const char* colorRed = options->temperatureColorRed.chars; + const char* colorGreen = options->tempColorGreen.chars; + const char* colorYellow = options->tempColorYellow.chars; + const char* colorRed = options->tempColorRed.chars; uint8_t green = config.green, yellow = config.yellow; @@ -40,13 +40,13 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi switch (options->temperatureUnit) { case FF_TEMPERATURE_UNIT_CELSIUS: - ffStrbufAppendF(buffer, "%.*f°C", options->temperatureNdigits, celsius); + ffStrbufAppendF(buffer, "%.*f°C", options->tempNdigits, celsius); break; case FF_TEMPERATURE_UNIT_FAHRENHEIT: - ffStrbufAppendF(buffer, "%.*f°F", options->temperatureNdigits, celsius * 1.8 + 32); + ffStrbufAppendF(buffer, "%.*f°F", options->tempNdigits, celsius * 1.8 + 32); break; case FF_TEMPERATURE_UNIT_KELVIN: - ffStrbufAppendF(buffer, "%.*f K", options->temperatureNdigits, celsius + 273.15); + ffStrbufAppendF(buffer, "%.*f K", options->tempNdigits, celsius + 273.15); break; } diff --git a/src/data/help.json b/src/data/help.json index 9fa6dd08a..621d2d71e 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -656,7 +656,7 @@ } }, { - "long": "temperature-unit", + "long": "temp-unit", "desc": "Set the unit of the temperature", "arg": { "type": "enum", @@ -669,7 +669,7 @@ } }, { - "long": "temperature-ndigits", + "long": "temp-ndigits", "desc": "Set the number of digits to keep after the decimal point when printing temperature", "arg": { "type": "num", @@ -677,7 +677,7 @@ } }, { - "long": "temperature-color-green", + "long": "temp-color-green", "desc": "Set color used in green state of temperature values", "remark": "See `-h color` for the list of available colors", "arg": { @@ -686,7 +686,7 @@ } }, { - "long": "temperature-color-yellow", + "long": "temp-color-yellow", "desc": "Set color used in yellow state of temperature values", "remark": "See `-h color` for the list of available colors", "arg": { @@ -695,7 +695,7 @@ } }, { - "long": "temperature-color-red", + "long": "temp-color-red", "desc": "Set color used in red state of temperature values", "remark": "See `-h color` for the list of available colors", "arg": { diff --git a/src/options/display.c b/src/options/display.c index 7adccaa8c..528c46e80 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -94,10 +94,10 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va yyjson_val* ndigits = yyjson_obj_get(val, "ndigits"); if (ndigits) options->percentNdigits = (uint8_t) yyjson_get_uint(ndigits); } - else if (ffStrEqualsIgnCase(key, "temperature")) + else if (ffStrEqualsIgnCase(key, "temp")) { if (!yyjson_is_obj(val)) - return "display.temperature must be an object"; + return "display.temp must be an object"; yyjson_val* unit = yyjson_obj_get(val, "unit"); if (unit) @@ -117,7 +117,7 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va } yyjson_val* ndigits = yyjson_obj_get(val, "ndigits"); - if (ndigits) options->temperatureNdigits = (uint8_t) yyjson_get_uint(ndigits); + if (ndigits) options->tempNdigits = (uint8_t) yyjson_get_uint(ndigits); yyjson_val* color = yyjson_obj_get(val, "color"); if (color) @@ -126,13 +126,13 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va return "display.temperature.color must be an object"; yyjson_val* green = yyjson_obj_get(color, "green"); - if (green) ffOptionParseColor(yyjson_get_str(green), &options->temperatureColorGreen); + if (green) ffOptionParseColor(yyjson_get_str(green), &options->tempColorGreen); yyjson_val* yellow = yyjson_obj_get(color, "yellow"); - if (yellow) ffOptionParseColor(yyjson_get_str(yellow), &options->temperatureColorYellow); + if (yellow) ffOptionParseColor(yyjson_get_str(yellow), &options->tempColorYellow); yyjson_val* red = yyjson_obj_get(color, "red"); - if (red) ffOptionParseColor(yyjson_get_str(red), &options->temperatureColorRed); + if (red) ffOptionParseColor(yyjson_get_str(red), &options->tempColorRed); } } else if (ffStrEqualsIgnCase(key, "percent")) @@ -295,13 +295,13 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key }); } else if (ffStrEqualsIgnCase(subkey, "ndigits")) - options->temperatureNdigits = (uint8_t) ffOptionParseUInt32(key, value); + options->tempNdigits = (uint8_t) ffOptionParseUInt32(key, value); else if(ffStrEqualsIgnCase(subkey, "color-green")) - ffOptionParseColor(value, &options->temperatureColorGreen); + ffOptionParseColor(value, &options->tempColorGreen); else if(ffStrEqualsIgnCase(subkey, "color-yellow")) - ffOptionParseColor(value, &options->temperatureColorYellow); + ffOptionParseColor(value, &options->tempColorYellow); else if(ffStrEqualsIgnCase(subkey, "color-red")) - ffOptionParseColor(value, &options->temperatureColorRed); + ffOptionParseColor(value, &options->tempColorRed); else return false; } @@ -368,10 +368,10 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options) options->keyWidth = 0; options->temperatureUnit = FF_TEMPERATURE_UNIT_CELSIUS; - options->temperatureNdigits = 1; - ffStrbufInitStatic(&options->temperatureColorGreen, FF_COLOR_FG_GREEN); - ffStrbufInitStatic(&options->temperatureColorYellow, FF_COLOR_FG_LIGHT_YELLOW); - ffStrbufInitStatic(&options->temperatureColorRed, FF_COLOR_FG_LIGHT_RED); + options->tempNdigits = 1; + ffStrbufInitStatic(&options->tempColorGreen, FF_COLOR_FG_GREEN); + ffStrbufInitStatic(&options->tempColorYellow, FF_COLOR_FG_LIGHT_YELLOW); + ffStrbufInitStatic(&options->tempColorRed, FF_COLOR_FG_LIGHT_RED); ffStrbufInitStatic(&options->barCharElapsed, "■"); ffStrbufInitStatic(&options->barCharTotal, "-"); @@ -492,21 +492,21 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do break; } } - if (options->temperatureNdigits != defaultOptions.temperatureNdigits) - yyjson_mut_obj_add_uint(doc, temperature, "ndigits", options->temperatureNdigits); + if (options->tempNdigits != defaultOptions.tempNdigits) + yyjson_mut_obj_add_uint(doc, temperature, "ndigits", options->tempNdigits); { yyjson_mut_val* color = yyjson_mut_obj(doc); - if (!ffStrbufEqual(&options->temperatureColorGreen, &defaultOptions.temperatureColorGreen)) - yyjson_mut_obj_add_strbuf(doc, color, "green", &options->temperatureColorGreen); - if (!ffStrbufEqual(&options->temperatureColorYellow, &defaultOptions.temperatureColorYellow)) - yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->temperatureColorYellow); - if (!ffStrbufEqual(&options->temperatureColorRed, &defaultOptions.temperatureColorRed)) - yyjson_mut_obj_add_strbuf(doc, color, "red", &options->temperatureColorRed); + if (!ffStrbufEqual(&options->tempColorGreen, &defaultOptions.tempColorGreen)) + yyjson_mut_obj_add_strbuf(doc, color, "green", &options->tempColorGreen); + if (!ffStrbufEqual(&options->tempColorYellow, &defaultOptions.tempColorYellow)) + yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->tempColorYellow); + if (!ffStrbufEqual(&options->tempColorRed, &defaultOptions.tempColorRed)) + yyjson_mut_obj_add_strbuf(doc, color, "red", &options->tempColorRed); if (yyjson_mut_obj_size(color) > 0) yyjson_mut_obj_add_val(doc, temperature, "color", color); } if (yyjson_mut_obj_size(temperature) > 0) - yyjson_mut_obj_add_val(doc, obj, "temperature", temperature); + yyjson_mut_obj_add_val(doc, obj, "temp", temperature); } { diff --git a/src/options/display.h b/src/options/display.h index 2d800150e..ef02336cb 100644 --- a/src/options/display.h +++ b/src/options/display.h @@ -35,10 +35,10 @@ typedef struct FFOptionsDisplay uint8_t sizeNdigits; uint8_t sizeMaxPrefix; FFTemperatureUnit temperatureUnit; - uint8_t temperatureNdigits; - FFstrbuf temperatureColorGreen; - FFstrbuf temperatureColorYellow; - FFstrbuf temperatureColorRed; + uint8_t tempNdigits; + FFstrbuf tempColorGreen; + FFstrbuf tempColorYellow; + FFstrbuf tempColorRed; FFstrbuf barCharElapsed; FFstrbuf barCharTotal; uint8_t barWidth;