mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
Display: print preferred resolution & refresh rate in custom format
Fix #1406
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_DISPLAY_NUM_FORMAT_ARGS 21
|
||||
#define FF_DISPLAY_NUM_FORMAT_ARGS 24
|
||||
|
||||
static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b)
|
||||
{
|
||||
@@ -164,6 +164,17 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
else
|
||||
refreshRate[0] = 0;
|
||||
|
||||
char preferredRefreshRate[16];
|
||||
if(result->preferredRefreshRate > 0)
|
||||
{
|
||||
if(options->preciseRefreshRate)
|
||||
snprintf(preferredRefreshRate, ARRAY_SIZE(preferredRefreshRate), "%g", ((int) (result->preferredRefreshRate * 1000 + 0.5)) / 1000.0);
|
||||
else
|
||||
snprintf(preferredRefreshRate, ARRAY_SIZE(preferredRefreshRate), "%i", (uint32_t) (result->preferredRefreshRate + 0.5));
|
||||
}
|
||||
else
|
||||
preferredRefreshRate[0] = 0;
|
||||
|
||||
char buf[32];
|
||||
if (result->serial)
|
||||
{
|
||||
@@ -197,6 +208,9 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
FF_FORMAT_ARG(result->platformApi, "platform-api"),
|
||||
FF_FORMAT_ARG(hdrCompatible, "hdr-compatible"),
|
||||
FF_FORMAT_ARG(scaleFactor, "scale-factor"),
|
||||
FF_FORMAT_ARG(result->preferredWidth, "preferred-width"),
|
||||
FF_FORMAT_ARG(result->preferredHeight, "preferred-height"),
|
||||
FF_FORMAT_ARG(preferredRefreshRate, "preferred-refresh-rate"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -424,9 +438,9 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs
|
||||
void ffPrintDisplayHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen width (in pixels) - width",
|
||||
"Screen height (in pixels) - height",
|
||||
"Screen refresh rate (in Hz) - refresh-rate",
|
||||
"Screen configured width (in pixels) - width",
|
||||
"Screen configured height (in pixels) - height",
|
||||
"Screen configured refresh rate (in Hz) - refresh-rate",
|
||||
"Screen scaled width (in pixels) - scaled-width",
|
||||
"Screen scaled height (in pixels) - scaled-height",
|
||||
"Screen name - name",
|
||||
@@ -445,6 +459,9 @@ void ffPrintDisplayHelpFormat(void)
|
||||
"The platform API used when detecting the display - platform-api",
|
||||
"True if the display is HDR compatible - hdr-compatible",
|
||||
"HiDPI scale factor - scale-factor",
|
||||
"Screen preferred width (in pixels) - preferred-width",
|
||||
"Screen preferred height (in pixels) - preferred-height",
|
||||
"Screen preferred refresh rate (in Hz) - preferred-refresh-rate",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user