mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 15:53:51 +01:00
Chore: run clang-format
```bash find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i ```
This commit is contained in:
@@ -6,79 +6,73 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
bool ffPrintMonitor(FFMonitorOptions* options)
|
||||
{
|
||||
bool ffPrintMonitor(FFMonitorOptions* options) {
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
|
||||
if(!result->displays.length)
|
||||
{
|
||||
if (!result->displays.length) {
|
||||
ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No display detected");
|
||||
return false;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
uint32_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFDisplayResult, display, result->displays)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFDisplayResult, display, result->displays) {
|
||||
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;
|
||||
bool hdrCompatible = display->hdrStatus == FF_DISPLAY_HDR_STATUS_SUPPORTED || display->hdrStatus == FF_DISPLAY_HDR_STATUS_ENABLED;
|
||||
|
||||
ffStrbufClear(&key);
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.key.length == 0) {
|
||||
ffStrbufAppendS(&key, FF_MONITOR_MODULE_NAME);
|
||||
if (display->name.length > 0)
|
||||
if (display->name.length > 0) {
|
||||
ffStrbufAppendF(&key, " (%s)", display->name.chars);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
} else {
|
||||
uint32_t moduleIndex = result->displays.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_ARG(moduleIndex, "index"),
|
||||
FF_ARG(display->name, "name"),
|
||||
FF_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
}));
|
||||
FF_ARG(moduleIndex, "index"),
|
||||
FF_ARG(display->name, "name"),
|
||||
FF_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
}));
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
|
||||
|
||||
printf("%ux%u px", display->width, display->height);
|
||||
if (display->refreshRate > 0)
|
||||
if (display->refreshRate > 0) {
|
||||
printf(" @ %g Hz", ((int) (display->refreshRate * 1000 + 0.5)) / 1000.0);
|
||||
if (inch > 0)
|
||||
}
|
||||
if (inch > 0) {
|
||||
printf(" - %ux%u mm (%.2f inches, %.2f ppi)", display->physicalWidth, display->physicalHeight, inch, ppi);
|
||||
if (hdrCompatible)
|
||||
}
|
||||
if (hdrCompatible) {
|
||||
fputs(" [HDR Compatible]", stdout);
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char buf[32];
|
||||
if (display->serial)
|
||||
{
|
||||
if (display->serial) {
|
||||
const uint8_t* nums = (uint8_t*) &display->serial;
|
||||
snprintf(buf, sizeof(buf), "%2X-%2X-%2X-%2X", nums[0], nums[1], nums[2], nums[3]);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_ARG(display->name, "name"),
|
||||
FF_ARG(display->width, "width"),
|
||||
FF_ARG(display->height, "height"),
|
||||
FF_ARG(display->physicalWidth, "physical-width"),
|
||||
FF_ARG(display->physicalHeight, "physical-height"),
|
||||
FF_ARG(inch, "inch"),
|
||||
FF_ARG(ppi, "ppi"),
|
||||
FF_ARG(display->manufactureYear, "manufacture-year"),
|
||||
FF_ARG(display->manufactureWeek, "manufacture-week"),
|
||||
FF_ARG(buf, "serial"),
|
||||
FF_ARG(display->refreshRate, "refresh-rate"),
|
||||
FF_ARG(hdrCompatible, "hdr-compatible"),
|
||||
}));
|
||||
FF_ARG(display->name, "name"),
|
||||
FF_ARG(display->width, "width"),
|
||||
FF_ARG(display->height, "height"),
|
||||
FF_ARG(display->physicalWidth, "physical-width"),
|
||||
FF_ARG(display->physicalHeight, "physical-height"),
|
||||
FF_ARG(inch, "inch"),
|
||||
FF_ARG(ppi, "ppi"),
|
||||
FF_ARG(display->manufactureYear, "manufacture-year"),
|
||||
FF_ARG(display->manufactureWeek, "manufacture-week"),
|
||||
FF_ARG(buf, "serial"),
|
||||
FF_ARG(display->refreshRate, "refresh-rate"),
|
||||
FF_ARG(hdrCompatible, "hdr-compatible"),
|
||||
}));
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&display->name);
|
||||
@@ -88,37 +82,32 @@ bool ffPrintMonitor(FFMonitorOptions* options)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseMonitorJsonObject(FFMonitorOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseMonitorJsonObject(FFMonitorOptions* options, yyjson_val* module) {
|
||||
yyjson_val *key, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key, val)
|
||||
{
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
yyjson_obj_foreach (module, idx, max, key, val) {
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_MONITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateMonitorJsonConfig(FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateMonitorJsonConfig(FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "Monitor module is an alias of Display module");
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffInitMonitorOptions(FFMonitorOptions* options)
|
||||
{
|
||||
void ffInitMonitorOptions(FFMonitorOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
void ffDestroyMonitorOptions(FFMonitorOptions* options)
|
||||
{
|
||||
void ffDestroyMonitorOptions(FFMonitorOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -144,5 +133,4 @@ FFModuleBaseInfo ffMonitorModuleInfo = {
|
||||
{"Serial number", "serial"},
|
||||
{"Maximum refresh rate in Hz", "refresh-rate"},
|
||||
{"True if the display is HDR compatible", "hdr-compatible"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFMonitorOptions
|
||||
{
|
||||
typedef struct FFMonitorOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFMonitorOptions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user