From 17e4b7e70d762f7f08f3c837abe7ee74e1456788 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 15 Sep 2021 08:50:14 +0200 Subject: [PATCH] graphics() XML parser improvement (macOS) --- CHANGELOG.md | 1 + README.md | 3 +- docs/graphics.html | 110 ++++++++++++++++++++++++++++++++++++++++----- docs/history.html | 5 +++ docs/index.html | 4 +- lib/graphics.js | 13 +++++- 6 files changed, 121 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c65c6fc..8729c31 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.9.0 | 2021-09-15 | `graphics()` new XML parser, added properties (macOS) | | 5.8.9 | 2021-09-13 | `battery()` fix linux | | 5.8.8 | 2021-09-11 | `wifiConnections()`, `wifiInterfaces()`, `wifiNetworks()` fix windows | | 5.8.7 | 2021-09-01 | `processes()` fix alpine linux | diff --git a/README.md b/README.md index a607d82..e149935 100644 --- a/README.md +++ b/README.md @@ -95,14 +95,13 @@ si.cpu() .catch(error => console.error(error)); ``` -**Callback, Promises, Async / Await** - ## News and Changes ### Latest Activity (last 7 major and minor version releases) +- Version 5.9.0: `graphics()` added properties (macOS) - Version 5.8.0: `disksIO()` added waitTime, waitPercent (linux) - Version 5.7.0: `diskLayout()` added S.M.A.R.T for Windows (if installed) - Version 5.6.0: `cpuTemperature()` added added socket and chipset temp (linux) diff --git a/docs/graphics.html b/docs/graphics.html index 0071212..4930a96 100644 --- a/docs/graphics.html +++ b/docs/graphics.html @@ -86,16 +86,6 @@ graphics controllers array - - - ...[0].model - X - - X - X - - graphics controller model - ...[0].vendor @@ -106,6 +96,16 @@ e.g. ATI + + + ...[0].model + X + + X + X + + graphics controller model + ...[0].bus @@ -136,6 +136,56 @@ true if dynamicly allocated ram + + + ...[0].deviceId + + + X + + + device ID (macOS only) + + + + ...[0].vendorId + + + X + + + vendor ID (macOS only) + + + + ...[0].external + + + X + + + is external GPU (macOS only) + + + + ...[0].cores + + + X + + + GPU cores (Apple silicon only) + + + + ...[0].metalVersion + + + X + + + Metal Version (macOS only) + ...[0].subDeviceId @@ -316,6 +366,16 @@ monitor/display vendor + + + ...[0].vendorId + + + X + + + monitor/display vendor ID (macOS only) + ...[0].deviceName @@ -336,6 +396,36 @@ monitor/display model + + + ...[0].productionYear + + + X + + + production year (macOS only) + + + + ...[0].serial + + + X + + + serial number (macOS only) + + + + ...[0].displayId + + + X + + + disoplay ID (macOS only) + ...[0].main diff --git a/docs/history.html b/docs/history.html index 25a72b5..cd73882 100644 --- a/docs/history.html +++ b/docs/history.html @@ -56,6 +56,11 @@ + + 5.9.0 + 2021-09-15 + graphics() macOS new XML parser, extended properties + 5.8.9 2021-09-13 diff --git a/docs/index.html b/docs/index.html index d7b41de..8e3ed67 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.8.9
+
New Version: 5.9.0
@@ -203,7 +203,7 @@
-
14,587
+
14,629
Lines of code
diff --git a/lib/graphics.js b/lib/graphics.js index 61c5a92..3ce3987 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -103,6 +103,17 @@ function getVendorFromId(id) { return vendors[id] || ''; } +function vendorToId(str) { + let result = ''; + str = (str || '').toLowerCase(); + if (str.indexOf('apple') >= 0) { result = '0x05ac'; } + else if (str.indexOf('nvidia') >= 0) { result = '0x10de'; } + else if (str.indexOf('intel') >= 0) { result = '0x8086'; } + else if (str.indexOf('ati') >= 0 || str.indexOf('amd') >= 0) { result = '0x1002'; } + + return result; +} + function getMetalVersion(id) { const families = { 'spdisplays_mtlgpufamilymac1': 'mac1', @@ -139,7 +150,7 @@ function graphics(callback) { vramDynamic: bus === 'Built-In', vram: vram || vramDyn || 0, deviceId: item['spdisplays_device-id'] || '', - vendorId: item['spdisplays_vendor-id'] || '', + vendorId: item['spdisplays_vendor-id'] || vendorToId((item['spdisplays_vendor'] || '') + (item.sppci_model || '')), external: (item.sppci_device_type === 'spdisplays_egpu'), cores: item['sppci_cores'] || null, metalVersion