From 674618930d3c76c5587c9f300a5964b0f5fa6954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Jul 2023 23:11:39 +0800 Subject: [PATCH] DisplayServer: add option `--ds-force-drm` Fixes #505 --- doc/json_schema.json | 8 ++++- src/common/init.c | 1 + src/common/jsonconfig.c | 2 ++ src/data/config_user.txt | 8 +++++ src/data/help.txt | 1 + .../displayserver/linux/displayserver_linux.c | 31 ++++++++++--------- src/fastfetch.c | 2 ++ src/fastfetch.h | 1 + 8 files changed, 39 insertions(+), 15 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index a4eed6218..8e54130d1 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -240,9 +240,15 @@ "type": "string", "title": "Set the path to the file containing OS information. Linux only" }, + "dsForceDrm": { + "type": "boolean", + "title": "Force display detection to use `/sys/class/drm`. Linux only", + "default": false + }, "wmiTimeout": { "type": "integer", - "title": "Set the timeout (ms) for WMI queries, `-1` for no timeout. Windows only" + "title": "Set the timeout (ms) for WMI queries, `-1` for no timeout. Windows only", + "default": 5000 } }, "additionalProperties": false diff --git a/src/common/init.c b/src/common/init.c index 50794b3d7..8ffadbc98 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -41,6 +41,7 @@ static void defaultConfig(void) #if defined(__linux__) || defined(__FreeBSD__) ffStrbufInit(&instance.config.playerName); ffStrbufInit(&instance.config.osFile); + instance.config.dsForceDrm = false; #elif defined(_WIN32) instance.config.wmiTimeout = 5000; #endif diff --git a/src/common/jsonconfig.c b/src/common/jsonconfig.c index 0b327ca4f..1b91c0035 100644 --- a/src/common/jsonconfig.c +++ b/src/common/jsonconfig.c @@ -318,6 +318,8 @@ const char* ffParseGeneralJsonConfig(void) ffStrbufSetS(&config->playerName, yyjson_get_str(val)); else if (ffStrEqualsIgnCase(key, "osFile")) ffStrbufSetS(&config->osFile, yyjson_get_str(val)); + else if (ffStrEqualsIgnCase(key, "dsForceDrm")) + config->dsForceDrm = yyjson_get_bool(val); #elif defined(_WIN32) else if (ffStrEqualsIgnCase(key, "wmiTimeout")) config->wmiTimeout = (int32_t) yyjson_get_int(val); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index e7ea439e0..29152b3d8 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -250,6 +250,14 @@ # Default is the first match starting with org.mpris.MediaPlayer2. #--player-name spotify +# Display server force DRM option +# Sets if fastfetch should only use `/sys/class/drm` to detect displays if you get issues with the default behavior. +# Note DRM doesn't support refresh rate or scaled resolution detection. +# Only supported on Linux. +# Must be true or false. +# Default is false. +#--ds-force-drm false + # Escape bedrock option # Sets if fastfetch should escape the bedrock jail, if it detectes that it is running in one # Must be true or false. diff --git a/src/data/help.txt b/src/data/help.txt index 097fc518d..f2cc97318 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -26,6 +26,7 @@ General options: --pipe : Disable logo and all escape sequences --wmi-timeout : Set the timeout (ms) for WMI queries. Windows only. Default is 5000 --processing-timeout : Set the timeout (ms) when waiting for child processes. Default is 1000 + --ds-force-drm : Set if only DRM should be used to detect displays. Default is false Logo options: -l,--logo : Set the logo; if default, the name of a builtin logo or a path to a file diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 506f519b1..13ffcf5e6 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -75,25 +75,28 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->deVersion); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); - //We try wayland as our prefered display server, as it supports the most features. - //This method can't detect the name of our WM / DE - ffdsConnectWayland(ds); + if (!instance.config.dsForceDrm) + { + //We try wayland as our prefered display server, as it supports the most features. + //This method can't detect the name of our WM / DE + ffdsConnectWayland(ds); - //Try the x11 libs, from most feature rich to least. - //We use the display list to detect if a connection is needed. - //They respect wmProtocolName, and only detect display if it is set. + //Try the x11 libs, from most feature rich to least. + //We use the display list to detect if a connection is needed. + //They respect wmProtocolName, and only detect display if it is set. - if(ds->displays.length == 0) - ffdsConnectXcbRandr(ds); + if(ds->displays.length == 0) + ffdsConnectXcbRandr(ds); - if(ds->displays.length == 0) - ffdsConnectXrandr(ds); + if(ds->displays.length == 0) + ffdsConnectXrandr(ds); - if(ds->displays.length == 0) - ffdsConnectXcb(ds); + if(ds->displays.length == 0) + ffdsConnectXcb(ds); - if(ds->displays.length == 0) - ffdsConnectXlib(ds); + if(ds->displays.length == 0) + ffdsConnectXlib(ds); + } //This display detection method is display server independent. //Use it if all connections failed diff --git a/src/fastfetch.c b/src/fastfetch.c index f7fa7f3d4..2b0ac906f 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -869,6 +869,8 @@ static void parseOption(FFdata* data, const char* key, const char* value) ffOptionParseString(key, value, &instance.config.playerName); else if (ffStrEqualsIgnCase(key, "--os-file")) ffOptionParseString(key, value, &instance.config.osFile); + else if(ffStrEqualsIgnCase(key, "--ds-force-drm")) + instance.config.dsForceDrm = ffOptionParseBoolean(value); #elif defined(_WIN32) else if (ffStrEqualsIgnCase(key, "--wmi-timeout")) instance.config.wmiTimeout = ffOptionParseInt32(key, value); diff --git a/src/fastfetch.h b/src/fastfetch.h index f54334eca..fde4923f1 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -61,6 +61,7 @@ typedef struct FFconfig #if defined(__linux__) || defined(__FreeBSD__) FFstrbuf playerName; FFstrbuf osFile; + bool dsForceDrm; #elif defined(_WIN32) int32_t wmiTimeout; #endif