mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
PhysicalDisplay: fix typo
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ Changes:
|
||||
* Fix M2 CPU temperature detection (CPU, macOS)
|
||||
|
||||
Features:
|
||||
* FreeBSD support is improved greatly, and actually tested in a phycial machine
|
||||
* FreeBSD support is improved greatly, and actually tested in a physical machine
|
||||
* Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled.
|
||||
* Support `--*-key-color` option to change the key color of specified module
|
||||
* Support `--colors-symbol` and `--colors-padding-left` (Colors)
|
||||
|
||||
+6
-6
@@ -328,7 +328,7 @@ set(LIBFASTFETCH_SRC
|
||||
src/modules/locale/locale.c
|
||||
src/modules/localip/localip.c
|
||||
src/modules/memory/memory.c
|
||||
src/modules/phycialdisplay/phycialdisplay.c
|
||||
src/modules/physicaldisplay/physicaldisplay.c
|
||||
src/modules/opencl/opencl.c
|
||||
src/modules/opengl/opengl.c
|
||||
src/modules/os/os.c
|
||||
@@ -395,7 +395,7 @@ if(LINUX)
|
||||
src/detection/gamepad/gamepad_linux.c
|
||||
src/detection/media/media_linux.c
|
||||
src/detection/memory/memory_linux.c
|
||||
src/detection/phycialdisplay/phycialdisplay_linux.c
|
||||
src/detection/physicaldisplay/physicaldisplay_linux.c
|
||||
src/detection/opengl/opengl_linux.c
|
||||
src/detection/os/os_linux.c
|
||||
src/detection/packages/packages_linux.c
|
||||
@@ -441,7 +441,7 @@ elseif(ANDROID)
|
||||
src/detection/gamepad/gamepad_nosupport.c
|
||||
src/detection/media/media_nosupport.c
|
||||
src/detection/memory/memory_linux.c
|
||||
src/detection/phycialdisplay/phycialdisplay_nosupport.c
|
||||
src/detection/physicaldisplay/physicaldisplay_nosupport.c
|
||||
src/detection/opengl/opengl_linux.c
|
||||
src/detection/os/os_android.c
|
||||
src/detection/packages/packages_linux.c
|
||||
@@ -493,7 +493,7 @@ elseif(BSD)
|
||||
src/detection/gamepad/gamepad_bsd.c
|
||||
src/detection/media/media_linux.c
|
||||
src/detection/memory/memory_bsd.c
|
||||
src/detection/phycialdisplay/phycialdisplay_nosupport.c
|
||||
src/detection/physicaldisplay/physicaldisplay_nosupport.c
|
||||
src/detection/opengl/opengl_linux.c
|
||||
src/detection/os/os_linux.c
|
||||
src/detection/packages/packages_linux.c
|
||||
@@ -541,7 +541,7 @@ elseif(APPLE)
|
||||
src/detection/gamepad/gamepad_apple.c
|
||||
src/detection/media/media_apple.m
|
||||
src/detection/memory/memory_apple.c
|
||||
src/detection/phycialdisplay/phycialdisplay_apple.c
|
||||
src/detection/physicaldisplay/physicaldisplay_apple.c
|
||||
src/detection/opengl/opengl_apple.c
|
||||
src/detection/os/os_apple.m
|
||||
src/detection/packages/packages_apple.c
|
||||
@@ -588,7 +588,7 @@ elseif(WIN32)
|
||||
src/detection/gamepad/gamepad_windows.c
|
||||
src/detection/media/media_nosupport.c
|
||||
src/detection/memory/memory_windows.c
|
||||
src/detection/phycialdisplay/phycialdisplay_windows.c
|
||||
src/detection/physicaldisplay/physicaldisplay_windows.c
|
||||
src/detection/opengl/opengl_windows.c
|
||||
src/detection/os/os_windows.cpp
|
||||
src/detection/packages/packages_windows.c
|
||||
|
||||
@@ -95,7 +95,7 @@ All categories not listed here should work without needing a specific implementa
|
||||
|
||||
##### Available Modules
|
||||
```
|
||||
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme
|
||||
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Physical Display, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme
|
||||
```
|
||||
|
||||
##### Builtin logos
|
||||
|
||||
@@ -493,6 +493,7 @@
|
||||
"opengl",
|
||||
"os",
|
||||
"packages",
|
||||
"physicaldisplay",
|
||||
"player",
|
||||
"poweradapter",
|
||||
"processes",
|
||||
@@ -564,6 +565,7 @@
|
||||
"opencl",
|
||||
"os",
|
||||
"packages",
|
||||
"physicaldisplay",
|
||||
"player",
|
||||
"poweradapter",
|
||||
"processes",
|
||||
|
||||
@@ -159,7 +159,7 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* module)
|
||||
|
||||
case 'N': {
|
||||
return
|
||||
tryModule(type, module, FF_PHYCIALDISPLAY_MODULE_NAME, ffParsePhycialDisplayJsonObject) ||
|
||||
tryModule(type, module, FF_PHYSICALDISPLAY_MODULE_NAME, ffParsePhysicalDisplayJsonObject) ||
|
||||
false;
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +372,7 @@
|
||||
#--publicip-key Public IP
|
||||
#--wifi-key Wifi
|
||||
#--weather-key Weather
|
||||
#--physicaldisplay-key Physical Display
|
||||
#--player-key Media Player
|
||||
#--media-key Media
|
||||
#--datetime-key Date Time
|
||||
@@ -421,6 +422,7 @@
|
||||
#--localip-format
|
||||
#--publicip-format
|
||||
#--weather-format
|
||||
#--physicaldisplay-format
|
||||
#--player-format
|
||||
#--media-format
|
||||
#--datetime-format
|
||||
@@ -467,6 +469,7 @@
|
||||
#--localip-key-color
|
||||
#--publicip-key-color
|
||||
#--weather-key-color
|
||||
#--physicaldisplay-key-color
|
||||
#--player-key-color
|
||||
#--media-key-color
|
||||
#--datetime-key-color
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFPhycialDisplayResult
|
||||
{
|
||||
FFstrbuf name;
|
||||
uint32_t width; // native / maximum resolution, in pixels
|
||||
uint32_t height; // native / maximum resolution, in pixels
|
||||
uint32_t phycialWidth; // in mm
|
||||
uint32_t phycialHeight; // in mm
|
||||
} FFPhycialDisplayResult;
|
||||
|
||||
const char* ffDetectPhycialDisplay(FFlist* results);
|
||||
@@ -1,6 +0,0 @@
|
||||
#include "phycialdisplay.h"
|
||||
|
||||
const char* ffDetectPhycialDisplay(FF_MAYBE_UNUSED FFlist* results)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFPhysicalDisplayResult
|
||||
{
|
||||
FFstrbuf name;
|
||||
uint32_t width; // native / maximum resolution, in pixels
|
||||
uint32_t height; // native / maximum resolution, in pixels
|
||||
uint32_t physicalWidth; // in mm
|
||||
uint32_t physicalHeight; // in mm
|
||||
} FFPhysicalDisplayResult;
|
||||
|
||||
const char* ffDetectPhysicalDisplay(FFlist* results);
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
#include "phycialdisplay.h"
|
||||
#include "physicaldisplay.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "util/apple/cf_helpers.h"
|
||||
#include "util/apple/ddcci.h"
|
||||
@@ -23,18 +23,18 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
|
||||
width <= 0 || height <= 0)
|
||||
continue;
|
||||
|
||||
FFPhycialDisplayResult* phycialDisplay = (FFPhycialDisplayResult*) ffListAdd(results);
|
||||
phycialDisplay->width = (uint32_t) width;
|
||||
phycialDisplay->height = (uint32_t) height;
|
||||
ffStrbufInit(&phycialDisplay->name);
|
||||
FFPhysicalDisplayResult* physicalDisplay = (FFPhysicalDisplayResult*) ffListAdd(results);
|
||||
physicalDisplay->width = (uint32_t) width;
|
||||
physicalDisplay->height = (uint32_t) height;
|
||||
ffStrbufInit(&physicalDisplay->name);
|
||||
|
||||
CFDictionaryRef productNames;
|
||||
if(!ffCfDictGetDict(displayInfo, CFSTR(kDisplayProductName), &productNames))
|
||||
ffCfDictGetString(productNames, CFSTR("en_US"), &phycialDisplay->name);
|
||||
ffCfDictGetString(productNames, CFSTR("en_US"), &physicalDisplay->name);
|
||||
|
||||
CGSize size = CGDisplayScreenSize((CGDirectDisplayID) display->id);
|
||||
phycialDisplay->phycialWidth = (uint32_t) (size.width + 0.5);
|
||||
phycialDisplay->phycialHeight = (uint32_t) (size.height + 0.5);
|
||||
physicalDisplay->physicalWidth = (uint32_t) (size.width + 0.5);
|
||||
physicalDisplay->physicalHeight = (uint32_t) (size.height + 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,20 +88,20 @@ static const char* detectWithDdcci(FFlist* results)
|
||||
|
||||
uint32_t width, height;
|
||||
const uint8_t* edidData = CFDataGetBytePtr(edid);
|
||||
ffEdidGetPhycialResolution(edidData, &width, &height);
|
||||
ffEdidGetPhysicalResolution(edidData, &width, &height);
|
||||
if (width == 0 || height == 0) continue;
|
||||
|
||||
FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results);
|
||||
FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results);
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
ffStrbufInit(&display->name);
|
||||
ffEdidGetName(edidData, &display->name);
|
||||
ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight);
|
||||
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ffDetectPhycialDisplay(FFlist* results)
|
||||
const char* ffDetectPhysicalDisplay(FFlist* results)
|
||||
{
|
||||
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
#include "phycialdisplay.h"
|
||||
#include "physicaldisplay.h"
|
||||
|
||||
#include "common/io/io.h"
|
||||
#include "util/edidHelper.h"
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
const char* ffDetectPhycialDisplay(FFlist* results)
|
||||
const char* ffDetectPhysicalDisplay(FFlist* results)
|
||||
{
|
||||
const char* drmDirPath = "/sys/class/drm/";
|
||||
|
||||
@@ -36,7 +36,7 @@ const char* ffDetectPhycialDisplay(FFlist* results)
|
||||
}
|
||||
|
||||
uint32_t width, height;
|
||||
ffEdidGetPhycialResolution(edidData, &width, &height);
|
||||
ffEdidGetPhysicalResolution(edidData, &width, &height);
|
||||
if (width != 0 && height != 0)
|
||||
{
|
||||
const char* plainName = entry->d_name;
|
||||
@@ -46,11 +46,11 @@ const char* ffDetectPhycialDisplay(FFlist* results)
|
||||
if (tmp) plainName = tmp + 1;
|
||||
}
|
||||
|
||||
FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results);
|
||||
FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results);
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
ffStrbufInitS(&display->name, plainName);
|
||||
ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight);
|
||||
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
|
||||
}
|
||||
|
||||
ffStrbufSubstrBefore(&drmDir, drmDirLength);
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "physicaldisplay.h"
|
||||
|
||||
const char* ffDetectPhysicalDisplay(FF_MAYBE_UNUSED FFlist* results)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
#include "phycialdisplay.h"
|
||||
#include "physicaldisplay.h"
|
||||
|
||||
#include "common/io/io.h"
|
||||
#include "util/edidHelper.h"
|
||||
@@ -16,7 +16,7 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
|
||||
SetupDiDestroyDeviceInfoList(*hdev);
|
||||
}
|
||||
|
||||
const char* ffDetectPhycialDisplay(FFlist* results)
|
||||
const char* ffDetectPhysicalDisplay(FFlist* results)
|
||||
{
|
||||
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
|
||||
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
|
||||
@@ -33,15 +33,15 @@ const char* ffDetectPhycialDisplay(FFlist* results)
|
||||
uint8_t edidData[256] = {};
|
||||
if (!ffRegReadData(hKey, L"EDID", edidData, sizeof(edidData), NULL)) continue;
|
||||
uint32_t width, height;
|
||||
ffEdidGetPhycialResolution(edidData, &width, &height);
|
||||
ffEdidGetPhysicalResolution(edidData, &width, &height);
|
||||
if (width == 0 || height == 0) continue;
|
||||
|
||||
FFPhycialDisplayResult* display = (FFPhycialDisplayResult*) ffListAdd(results);
|
||||
FFPhysicalDisplayResult* display = (FFPhysicalDisplayResult*) ffListAdd(results);
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
ffStrbufInit(&display->name);
|
||||
ffEdidGetName(edidData, &display->name);
|
||||
ffEdidGetPhycialSize(edidData, &display->phycialWidth, &display->phycialHeight);
|
||||
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
+14
-3
@@ -393,6 +393,17 @@ static inline void printCommandHelp(const char* command)
|
||||
"Connection Security algorithm"
|
||||
);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "physicaldisplay-format"))
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("physicaldisplay", "{}", 6,
|
||||
"Display name",
|
||||
"Display native resolution width in pixels",
|
||||
"Display native resolution height in pixels",
|
||||
"Display physical width in millimeters",
|
||||
"Display physical height in millimeters",
|
||||
"Display physical length in inches"
|
||||
);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "player-format"))
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("player", "{}", 4,
|
||||
@@ -1018,7 +1029,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {}
|
||||
else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {}
|
||||
else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {}
|
||||
else if(ffParsePhycialDisplayCommandOptions(&instance.config.nativeResolution, key, value)) {}
|
||||
else if(ffParsePhysicalDisplayCommandOptions(&instance.config.nativeResolution, key, value)) {}
|
||||
else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {}
|
||||
else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {}
|
||||
else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {}
|
||||
@@ -1252,8 +1263,8 @@ static void parseStructureCommand(const char* line, FFlist* customValues)
|
||||
ffPrintPlayer(&instance.config.player);
|
||||
else if(ffStrEqualsIgnCase(line, FF_MEDIA_MODULE_NAME))
|
||||
ffPrintMedia(&instance.config.media);
|
||||
else if(ffStrEqualsIgnCase(line, FF_PHYCIALDISPLAY_MODULE_NAME))
|
||||
ffPrintPhycialDisplay(&instance.config.nativeResolution);
|
||||
else if(ffStrEqualsIgnCase(line, FF_PHYSICALDISPLAY_MODULE_NAME))
|
||||
ffPrintPhysicalDisplay(&instance.config.nativeResolution);
|
||||
else if(ffStrEqualsIgnCase(line, FF_DATETIME_MODULE_NAME))
|
||||
ffPrintDateTime(&instance.config.dateTime);
|
||||
else if(ffStrEqualsIgnCase(line, FF_COLORS_MODULE_NAME))
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ typedef struct FFconfig
|
||||
FFWeatherOptions weather;
|
||||
FFPlayerOptions player;
|
||||
FFMediaOptions media;
|
||||
FFPhycialDisplayOptions nativeResolution;
|
||||
FFPhysicalDisplayOptions nativeResolution;
|
||||
FFDateTimeOptions dateTime;
|
||||
FFVulkanOptions vulkan;
|
||||
FFOpenGLOptions openGL;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "modules/localip/localip.h"
|
||||
#include "modules/media/media.h"
|
||||
#include "modules/memory/memory.h"
|
||||
#include "modules/phycialdisplay/phycialdisplay.h"
|
||||
#include "modules/physicaldisplay/physicaldisplay.h"
|
||||
#include "modules/opengl/opengl.h"
|
||||
#include "modules/opencl/opencl.h"
|
||||
#include "modules/os/os.h"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "modules/localip/option.h"
|
||||
#include "modules/media/option.h"
|
||||
#include "modules/memory/option.h"
|
||||
#include "modules/phycialdisplay/option.h"
|
||||
#include "modules/physicaldisplay/option.h"
|
||||
#include "modules/opengl/option.h"
|
||||
#include "modules/opencl/option.h"
|
||||
#include "modules/os/option.h"
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/phycialdisplay/phycialdisplay.h"
|
||||
#include "modules/phycialdisplay/phycialdisplay.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_PHYCIALDISPLAY_DISPLAY_NAME "Phycial Display"
|
||||
#define FF_PHYCIALDISPLAY_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhycialDisplayResult));
|
||||
|
||||
const char* error = ffDetectPhycialDisplay(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(FF_PHYCIALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No phycial display detected");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_LIST_FOR_EACH(FFPhycialDisplayResult, display, result)
|
||||
{
|
||||
double inch = sqrt(display->phycialWidth * display->phycialWidth + display->phycialHeight * display->phycialHeight) / 25.4;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
{
|
||||
ffStrbufAppendF(&key, "%s (%s)", FF_PHYCIALDISPLAY_DISPLAY_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);
|
||||
|
||||
printf("%upx x %upx", display->width, display->height);
|
||||
if (inch > 0)
|
||||
printf(" - %umm x %umm (%.2f inches)\n", display->phycialWidth, display->phycialHeight, inch);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(FF_PHYCIALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYCIALDISPLAY_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},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->phycialWidth},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->phycialHeight},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &inch},
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&display->name);
|
||||
}
|
||||
}
|
||||
|
||||
void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options)
|
||||
{
|
||||
options->moduleName = FF_PHYCIALDISPLAY_MODULE_NAME;
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_PHYCIALDISPLAY_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePhycialDisplayJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPhycialDisplayOptions __attribute__((__cleanup__(ffDestroyPhycialDisplayOptions))) options;
|
||||
ffInitPhycialDisplayOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_PHYCIALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPhycialDisplay(&options);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_PHYCIALDISPLAY_MODULE_NAME "PhycialDisplay"
|
||||
|
||||
void ffPrintPhycialDisplay(FFPhycialDisplayOptions* options);
|
||||
void ffInitPhycialDisplayOptions(FFPhycialDisplayOptions* options);
|
||||
bool ffParsePhycialDisplayCommandOptions(FFPhycialDisplayOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPhycialDisplayOptions(FFPhycialDisplayOptions* options);
|
||||
void ffParsePhycialDisplayJsonObject(yyjson_val* module);
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFPhycialDisplayOptions
|
||||
typedef struct FFPhysicalDisplayOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFPhycialDisplayOptions;
|
||||
} FFPhysicalDisplayOptions;
|
||||
@@ -0,0 +1,117 @@
|
||||
#include "common/printing.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "detection/physicaldisplay/physicaldisplay.h"
|
||||
#include "modules/physicaldisplay/physicaldisplay.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_PHYSICALDISPLAY_DISPLAY_NAME "Physical Display"
|
||||
#define FF_PHYSICALDISPLAY_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalDisplayResult));
|
||||
|
||||
const char* error = ffDetectPhysicalDisplay(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(FF_PHYSICALDISPLAY_DISPLAY_NAME, 0, &options->moduleArgs, "No physical display detected");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_LIST_FOR_EACH(FFPhysicalDisplayResult, display, result)
|
||||
{
|
||||
double inch = sqrt(display->physicalWidth * display->physicalWidth + display->physicalHeight * display->physicalHeight) / 25.4;
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
if(options->moduleArgs.key.length == 0)
|
||||
{
|
||||
ffStrbufAppendF(&key, "%s (%s)", FF_PHYSICALDISPLAY_DISPLAY_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);
|
||||
|
||||
printf("%upx x %upx", display->width, display->height);
|
||||
if (inch > 0)
|
||||
printf(" - %umm x %umm (%.2f inches)\n", display->physicalWidth, display->physicalHeight, inch);
|
||||
else
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(FF_PHYSICALDISPLAY_DISPLAY_NAME, index, &options->moduleArgs, FF_PHYSICALDISPLAY_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},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalWidth},
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &display->physicalHeight},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &inch},
|
||||
});
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&display->name);
|
||||
}
|
||||
}
|
||||
|
||||
void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options)
|
||||
{
|
||||
options->moduleName = FF_PHYSICALDISPLAY_MODULE_NAME;
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value)
|
||||
{
|
||||
const char* subKey = ffOptionTestPrefix(key, FF_PHYSICALDISPLAY_MODULE_NAME);
|
||||
if (!subKey) return false;
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffParsePhysicalDisplayJsonObject(yyjson_val* module)
|
||||
{
|
||||
FFPhysicalDisplayOptions __attribute__((__cleanup__(ffDestroyPhysicalDisplayOptions))) options;
|
||||
ffInitPhysicalDisplayOptions(&options);
|
||||
|
||||
if (module)
|
||||
{
|
||||
yyjson_val *key_, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key_, val)
|
||||
{
|
||||
const char* key = yyjson_get_str(key_);
|
||||
if(ffStrEqualsIgnCase(key, "type"))
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
ffPrintError(FF_PHYSICALDISPLAY_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
ffPrintPhysicalDisplay(&options);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
#define FF_PHYSICALDISPLAY_MODULE_NAME "PhysicalDisplay"
|
||||
|
||||
void ffPrintPhysicalDisplay(FFPhysicalDisplayOptions* options);
|
||||
void ffInitPhysicalDisplayOptions(FFPhysicalDisplayOptions* options);
|
||||
bool ffParsePhysicalDisplayCommandOptions(FFPhysicalDisplayOptions* options, const char* key, const char* value);
|
||||
void ffDestroyPhysicalDisplayOptions(FFPhysicalDisplayOptions* options);
|
||||
void ffParsePhysicalDisplayJsonObject(yyjson_val* module);
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "edidHelper.h"
|
||||
|
||||
void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height)
|
||||
void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height)
|
||||
{
|
||||
const int dtd = 54;
|
||||
*width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2];
|
||||
@@ -27,7 +27,7 @@ void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name)
|
||||
}
|
||||
}
|
||||
|
||||
void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height)
|
||||
void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height)
|
||||
{
|
||||
*width = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66];
|
||||
*height = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67];
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "util/FFstrbuf.h"
|
||||
|
||||
void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name);
|
||||
void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height);
|
||||
void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm
|
||||
void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height);
|
||||
void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user