diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f234390e..4cb37bc40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Features: * Support foot terminal (#431, Linux) * Support cursor size detection on Windows (Cursor, Windows) * Support cursor detection on macOS (Cursor, macOS) +* Support display name and decimal refresh rate detection (Display, macOS / Windows) Bugfixes: * Fix date time format diff --git a/src/common/init.c b/src/common/init.c index b9fa8472d..93547b177 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -162,6 +162,8 @@ static void defaultConfig(FFinstance* instance) instance->config.diskShowSubvolumes = false; instance->config.displayCompactType = FF_DISPLAY_COMPACT_TYPE_NONE; + instance->config.displayDetectName = false; + instance->config.displayPreciseRefreshRate = false; instance->config.bluetoothShowDisconnected = false; diff --git a/src/data/config_user.txt b/src/data/config_user.txt index aacbfcac6..5e1a72f43 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -253,12 +253,24 @@ # Default is false. #--bluetooth-show-disconnected false -# Display compact output +# Display compact output option # Sets if all displays should be printed in one line # Must be either original (print pixel resolution) or scaled (print scaled resolution) # Default is none. #--display-compact-type none +# Display detect name option +# Sets if display name should be detected and printed (if supported) +# Must be either true of false +# Default is false. +#--display-detect-name none + +# Display precise refresh rate option +# Sets if decimal refresh rates should not be rounded into integers when printing +# Must be either true (keep decimals) of false (round into integers) +# Default is false. +#--display-precise-refresh-rate false + # Sound show all option # Sets if all sound devices should be printed # Must be either main, active or all. Default is main diff --git a/src/data/help.txt b/src/data/help.txt index d77cd6cea..0c5ec6219 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -114,6 +114,8 @@ Module specific options: --disk-show-unknown : Set if unknown (unable to detect sizes) volumes should be printed. Default is false --bluetooth-show-disconnected: : Set if disconnected bluetooth devices should be printed. Default is false --display-compact-type: : Set if all displays should be printed in one line. Default is none + --display-detect-name: : Set if display name should be detected and printed (if supported). Default is false + --display-precise-refresh-rate: :Set if decimal refresh rates should not be rounded into integers when printing --sound-type: : Set what type of sound devices should be printed. Should be either main, active or all. Default is main --battery-dir : The directory where the battery folders are. Standard: /sys/class/power_supply/ --cpu-temp : Detect and display CPU temperature if supported. Default is false diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index 6db604114..5d07e4263 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -11,7 +11,7 @@ extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); -static void detectDisplays(FFDisplayServerResult* ds) +static void detectDisplays(FFDisplayServerResult* ds, bool detectName) { CGDirectDisplayID screens[128]; uint32_t screenCount; @@ -41,7 +41,7 @@ static void detectDisplays(FFDisplayServerResult* ds) FF_STRBUF_AUTO_DESTROY name; ffStrbufInit(&name); - if(CoreDisplay_DisplayCreateInfoDictionary) + if(detectName && CoreDisplay_DisplayCreateInfoDictionary) { CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); if(displayInfo) @@ -120,5 +120,5 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins ffStrbufAppendS(&ds->dePrettyName, "Aqua"); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); - detectDisplays(ds); + detectDisplays(ds, instance->config.displayDetectName); } diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index bbd40e38e..df71bf694 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -26,27 +26,8 @@ static CALLBACK WINBOOL enumMonitorProc(HMONITOR hMonitor, FF_MAYBE_UNUSED HDC h return TRUE; } -void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) +static void detectDisplays(FFDisplayServerResult* ds, bool detectName) { - FF_UNUSED(instance); - - BOOL enabled; - if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE) - { - ffStrbufInitS(&ds->wmProcessName, "dwm.exe"); - ffStrbufInitS(&ds->wmPrettyName, "Desktop Window Manager"); - } - else - { - ffStrbufInitS(&ds->wmProcessName, "internal"); - ffStrbufInitS(&ds->wmPrettyName, "internal"); - } - ffStrbufInit(&ds->wmProtocolName); - ffStrbufInit(&ds->deProcessName); - ffStrbufInit(&ds->dePrettyName); - ffStrbufInit(&ds->deVersion); - ffListInit(&ds->displays, sizeof(FFDisplayResult)); - DISPLAYCONFIG_PATH_INFO paths[128]; uint32_t pathCount = sizeof(paths) / sizeof(paths[0]); DISPLAYCONFIG_MODE_INFO modes[256]; @@ -94,7 +75,8 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins FF_STRBUF_AUTO_DESTROY name; ffStrbufInit(&name); - if(SUCCEEDED(DisplayConfigGetDeviceInfo(&targetName.header)) && targetName.flags.friendlyNameFromEdid) + + if(detectName && SUCCEEDED(DisplayConfigGetDeviceInfo(&targetName.header)) && targetName.flags.friendlyNameFromEdid) ffStrbufSetWS(&name, targetName.monitorFriendlyDeviceName); ffdsAppendDisplay(ds, @@ -106,6 +88,28 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins &name); } } +} + +void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance) +{ + BOOL enabled; + if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE) + { + ffStrbufInitS(&ds->wmProcessName, "dwm.exe"); + ffStrbufInitS(&ds->wmPrettyName, "Desktop Window Manager"); + } + else + { + ffStrbufInitS(&ds->wmProcessName, "internal"); + ffStrbufInitS(&ds->wmPrettyName, "internal"); + } + ffStrbufInit(&ds->wmProtocolName); + ffStrbufInit(&ds->deProcessName); + ffStrbufInit(&ds->dePrettyName); + ffStrbufInit(&ds->deVersion); + ffListInit(&ds->displays, sizeof(FFDisplayResult)); + + detectDisplays(ds, instance->config.displayDetectName); //https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067 const FFOSResult* os = ffDetectOS(instance); diff --git a/src/fastfetch.c b/src/fastfetch.c index d7f1e2e59..c46d11c2b 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1276,6 +1276,10 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con "scaled", FF_DISPLAY_COMPACT_TYPE_SCALED_BIT, NULL); } + else if(strcasecmp(key, "--display-precise-refresh-rate") == 0) + instance->config.displayPreciseRefreshRate = optionParseBoolean(value); + else if(strcasecmp(key, "--display-detect-name") == 0) + instance->config.displayDetectName = optionParseBoolean(value); else if(strcasecmp(key, "--bluetooth-show-disconnected") == 0) instance->config.bluetoothShowDisconnected = optionParseBoolean(value); else if(strcasecmp(key, "--sound-type") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 854af86cd..025b3254f 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -209,6 +209,8 @@ typedef struct FFconfig bool diskShowSubvolumes; FFDisplayCompactType displayCompactType; + bool displayDetectName; + bool displayPreciseRefreshRate; bool bluetoothShowDisconnected; diff --git a/src/modules/display.c b/src/modules/display.c index 1c7a43730..1c55d2f19 100644 --- a/src/modules/display.c +++ b/src/modules/display.c @@ -70,7 +70,12 @@ void ffPrintDisplay(FFinstance* instance) printf("%ix%i", result->width, result->height); if(result->refreshRate > 0) - printf(" @ %iHz", (uint32_t) (result->refreshRate + 0.5)); + { + if(instance->config.displayPreciseRefreshRate) + printf(" @ %gHz", ((int) (result->refreshRate * 1000 + 0.5)) / 1000.0); + else + printf(" @ %iHz", (uint32_t) (result->refreshRate + 0.5)); + } if( result->scaledWidth > 0 && result->scaledWidth != result->width &&