From 8035902cb2beca096ac8811b50f9a2881f248de1 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 15 Jun 2021 08:31:47 +0200 Subject: [PATCH] graphics() improved detection screen resolution (macOS) --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 6 +++--- lib/graphics.js | 18 ++++++++++++++---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 145131f..7aa5026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.7.7 | 2021-06-15 | `graphics()` improved detection screen resolution (macOS) | | 5.7.6 | 2021-06-09 | `battery()` improved detection (additional batteries windows) | | 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) | | 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) | diff --git a/docs/history.html b/docs/history.html index fa11c5f..0359bfe 100644 --- a/docs/history.html +++ b/docs/history.html @@ -56,6 +56,11 @@ + + 5.7.7 + 2021-06-15 + graphics() improved detection screen resolution (macOS) + 5.7.6 2021-06-09 diff --git a/docs/index.html b/docs/index.html index 7d3caf6..6abd66f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.7.6
+
New Version: 5.7.7
@@ -203,7 +203,7 @@
-
14,231
+
14,473
Lines of code
@@ -211,7 +211,7 @@
Downloads last month
-
420
+
424
Dependents
diff --git a/lib/graphics.js b/lib/graphics.js index d2fd56b..a2c7925 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -172,10 +172,20 @@ function graphics(callback) { if (4 === level) { // display controller details level if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('resolution') !== -1) { let resolution = parts[1].split('x'); - currentDisplay.resolutionX = (resolution.length > 1 ? parseInt(resolution[0]) : 0); - currentDisplay.resolutionY = (resolution.length > 1 ? parseInt(resolution[1]) : 0); - currentDisplay.currentResX = currentDisplay.resolutionX; - currentDisplay.currentResY = currentDisplay.resolutionY; + if (resolution.length > 1) { + let xpart = resolution[0]; + if (xpart.indexOf('(') !== -1) { + xpart = xpart.split('(').slice(-1)[0]; + } + let ypart = resolution[1]; + if (ypart.indexOf(')') !== -1) { + ypart = ypart.split(')')[0]; + } + currentDisplay.resolutionX = parseInt(xpart) || 0; + currentDisplay.resolutionY = parseInt(ypart) || 0; + currentDisplay.currentResX = currentDisplay.resolutionX; + currentDisplay.currentResY = currentDisplay.resolutionY; + } } if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) { currentDisplay.pixelDepth = parseInt(parts[1]); } // in BIT if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) { currentDisplay.pixelDepth = parseInt(parts[1]); } // in BIT