systeminformation 5.27.16 → 5.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/lib/cpu.js +232 -39
- package/lib/graphics.js +348 -241
- package/lib/network.js +1 -1
- package/lib/system.js +246 -143
- package/lib/util.js +52 -51
- package/lib/wifi.js +120 -129
- package/package.json +1 -1
package/lib/graphics.js
CHANGED
|
@@ -21,13 +21,13 @@ const util = require('./util');
|
|
|
21
21
|
let _platform = process.platform;
|
|
22
22
|
let _nvidiaSmiPath = '';
|
|
23
23
|
|
|
24
|
-
const _linux =
|
|
25
|
-
const _darwin =
|
|
26
|
-
const _windows =
|
|
27
|
-
const _freebsd =
|
|
28
|
-
const _openbsd =
|
|
29
|
-
const _netbsd =
|
|
30
|
-
const _sunos =
|
|
24
|
+
const _linux = _platform === 'linux' || _platform === 'android';
|
|
25
|
+
const _darwin = _platform === 'darwin';
|
|
26
|
+
const _windows = _platform === 'win32';
|
|
27
|
+
const _freebsd = _platform === 'freebsd';
|
|
28
|
+
const _openbsd = _platform === 'openbsd';
|
|
29
|
+
const _netbsd = _platform === 'netbsd';
|
|
30
|
+
const _sunos = _platform === 'sunos';
|
|
31
31
|
|
|
32
32
|
let _resolutionX = 0;
|
|
33
33
|
let _resolutionY = 0;
|
|
@@ -37,22 +37,22 @@ let _refreshRate = 0;
|
|
|
37
37
|
const videoTypes = {
|
|
38
38
|
'-2': 'UNINITIALIZED',
|
|
39
39
|
'-1': 'OTHER',
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
0: 'HD15',
|
|
41
|
+
1: 'SVIDEO',
|
|
42
|
+
2: 'Composite video',
|
|
43
|
+
3: 'Component video',
|
|
44
|
+
4: 'DVI',
|
|
45
|
+
5: 'HDMI',
|
|
46
|
+
6: 'LVDS',
|
|
47
|
+
8: 'D_JPN',
|
|
48
|
+
9: 'SDI',
|
|
49
|
+
10: 'DP',
|
|
50
|
+
11: 'DP embedded',
|
|
51
|
+
12: 'UDI',
|
|
52
|
+
13: 'UDI embedded',
|
|
53
|
+
14: 'SDTVDONGLE',
|
|
54
|
+
15: 'MIRACAST',
|
|
55
|
+
2147483648: 'INTERNAL'
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
function getVendorFromModel(model) {
|
|
@@ -77,7 +77,7 @@ function getVendorFromModel(model) {
|
|
|
77
77
|
{ pattern: 'APPLE.?', manufacturer: 'Apple' },
|
|
78
78
|
{ pattern: 'INTEL.?', manufacturer: 'Intel' },
|
|
79
79
|
{ pattern: 'AMD.?', manufacturer: 'AMD' },
|
|
80
|
-
{ pattern: 'NVIDIA.?', manufacturer: 'NVDIA' }
|
|
80
|
+
{ pattern: 'NVIDIA.?', manufacturer: 'NVDIA' }
|
|
81
81
|
];
|
|
82
82
|
|
|
83
83
|
let result = '';
|
|
@@ -85,7 +85,9 @@ function getVendorFromModel(model) {
|
|
|
85
85
|
model = model.toUpperCase();
|
|
86
86
|
manufacturers.forEach((manufacturer) => {
|
|
87
87
|
const re = RegExp(manufacturer.pattern);
|
|
88
|
-
if (re.test(model)) {
|
|
88
|
+
if (re.test(model)) {
|
|
89
|
+
result = manufacturer.manufacturer;
|
|
90
|
+
}
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
93
|
return result;
|
|
@@ -93,11 +95,11 @@ function getVendorFromModel(model) {
|
|
|
93
95
|
|
|
94
96
|
function getVendorFromId(id) {
|
|
95
97
|
const vendors = {
|
|
96
|
-
|
|
98
|
+
610: 'Apple',
|
|
97
99
|
'1e6d': 'LG',
|
|
98
100
|
'10ac': 'DELL',
|
|
99
101
|
'4dd9': 'Sony',
|
|
100
|
-
'38a3': 'NEC'
|
|
102
|
+
'38a3': 'NEC'
|
|
101
103
|
};
|
|
102
104
|
return vendors[id] || '';
|
|
103
105
|
}
|
|
@@ -105,47 +107,51 @@ function getVendorFromId(id) {
|
|
|
105
107
|
function vendorToId(str) {
|
|
106
108
|
let result = '';
|
|
107
109
|
str = (str || '').toLowerCase();
|
|
108
|
-
if (str.indexOf('apple') >= 0) {
|
|
109
|
-
|
|
110
|
-
else if (str.indexOf('
|
|
111
|
-
|
|
110
|
+
if (str.indexOf('apple') >= 0) {
|
|
111
|
+
result = '0x05ac';
|
|
112
|
+
} else if (str.indexOf('nvidia') >= 0) {
|
|
113
|
+
result = '0x10de';
|
|
114
|
+
} else if (str.indexOf('intel') >= 0) {
|
|
115
|
+
result = '0x8086';
|
|
116
|
+
} else if (str.indexOf('ati') >= 0 || str.indexOf('amd') >= 0) {
|
|
117
|
+
result = '0x1002';
|
|
118
|
+
}
|
|
112
119
|
|
|
113
120
|
return result;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
function getMetalVersion(id) {
|
|
117
124
|
const families = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
spdisplays_mtlgpufamilymac1: 'mac1',
|
|
126
|
+
spdisplays_mtlgpufamilymac2: 'mac2',
|
|
127
|
+
spdisplays_mtlgpufamilyapple1: 'apple1',
|
|
128
|
+
spdisplays_mtlgpufamilyapple2: 'apple2',
|
|
129
|
+
spdisplays_mtlgpufamilyapple3: 'apple3',
|
|
130
|
+
spdisplays_mtlgpufamilyapple4: 'apple4',
|
|
131
|
+
spdisplays_mtlgpufamilyapple5: 'apple5',
|
|
132
|
+
spdisplays_mtlgpufamilyapple6: 'apple6',
|
|
133
|
+
spdisplays_mtlgpufamilyapple7: 'apple7',
|
|
134
|
+
spdisplays_metalfeaturesetfamily11: 'family1_v1',
|
|
135
|
+
spdisplays_metalfeaturesetfamily12: 'family1_v2',
|
|
136
|
+
spdisplays_metalfeaturesetfamily13: 'family1_v3',
|
|
137
|
+
spdisplays_metalfeaturesetfamily14: 'family1_v4',
|
|
138
|
+
spdisplays_metalfeaturesetfamily21: 'family2_v1'
|
|
132
139
|
};
|
|
133
140
|
return families[id] || '';
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
function graphics(callback) {
|
|
137
|
-
|
|
138
144
|
function parseLinesDarwin(graphicsArr) {
|
|
139
145
|
const res = {
|
|
140
146
|
controllers: [],
|
|
141
147
|
displays: []
|
|
142
148
|
};
|
|
143
149
|
try {
|
|
144
|
-
graphicsArr.forEach(
|
|
150
|
+
graphicsArr.forEach((item) => {
|
|
145
151
|
// controllers
|
|
146
|
-
const bus = (
|
|
147
|
-
const vram = (parseInt(
|
|
148
|
-
const vramDyn = (parseInt(
|
|
152
|
+
const bus = (item.sppci_bus || '').indexOf('builtin') > -1 ? 'Built-In' : (item.sppci_bus || '').indexOf('pcie') > -1 ? 'PCIe' : '';
|
|
153
|
+
const vram = (parseInt(item.spdisplays_vram || '', 10) || 0) * ((item.spdisplays_vram || '').indexOf('GB') > -1 ? 1024 : 1);
|
|
154
|
+
const vramDyn = (parseInt(item.spdisplays_vram_shared || '', 10) || 0) * ((item.spdisplays_vram_shared || '').indexOf('GB') > -1 ? 1024 : 1);
|
|
149
155
|
let metalVersion = getMetalVersion(item.spdisplays_metal || item.spdisplays_metalfamily || '');
|
|
150
156
|
res.controllers.push({
|
|
151
157
|
vendor: getVendorFromModel(item.spdisplays_vendor || '') || item.spdisplays_vendor || '',
|
|
@@ -155,14 +161,14 @@ function graphics(callback) {
|
|
|
155
161
|
vram: vram || vramDyn || null,
|
|
156
162
|
deviceId: item['spdisplays_device-id'] || '',
|
|
157
163
|
vendorId: item['spdisplays_vendor-id'] || vendorToId((item['spdisplays_vendor'] || '') + (item.sppci_model || '')),
|
|
158
|
-
external:
|
|
164
|
+
external: item.sppci_device_type === 'spdisplays_egpu',
|
|
159
165
|
cores: item['sppci_cores'] || null,
|
|
160
166
|
metalVersion
|
|
161
167
|
});
|
|
162
168
|
|
|
163
169
|
// displays
|
|
164
170
|
if (item.spdisplays_ndrvs && item.spdisplays_ndrvs.length) {
|
|
165
|
-
item.spdisplays_ndrvs.forEach(
|
|
171
|
+
item.spdisplays_ndrvs.forEach((displayItem) => {
|
|
166
172
|
const connectionType = displayItem['spdisplays_connection_type'] || '';
|
|
167
173
|
const currentResolutionParts = (displayItem['_spdisplays_resolution'] || '').split('@');
|
|
168
174
|
const currentResolution = currentResolutionParts[0].split('x');
|
|
@@ -178,18 +184,17 @@ function graphics(callback) {
|
|
|
178
184
|
displayId: displayItem['_spdisplays_displayID'] || null,
|
|
179
185
|
main: displayItem['spdisplays_main'] ? displayItem['spdisplays_main'] === 'spdisplays_yes' : false,
|
|
180
186
|
builtin: (displayItem['spdisplays_display_type'] || '').indexOf('built-in') > -1,
|
|
181
|
-
connection:
|
|
187
|
+
connection: connectionType.indexOf('_internal') > -1 ? 'Internal' : connectionType.indexOf('_displayport') > -1 ? 'Display Port' : connectionType.indexOf('_hdmi') > -1 ? 'HDMI' : null,
|
|
182
188
|
sizeX: null,
|
|
183
189
|
sizeY: null,
|
|
184
|
-
pixelDepth:
|
|
190
|
+
pixelDepth: pixelDepthString === 'CGSThirtyBitColor' ? 30 : pixelDepthString === 'CGSThirtytwoBitColor' ? 32 : pixelDepthString === 'CGSTwentyfourBitColor' ? 24 : null,
|
|
185
191
|
resolutionX: pixelParts.length > 1 ? parseInt(pixelParts[0], 10) : null,
|
|
186
192
|
resolutionY: pixelParts.length > 1 ? parseInt(pixelParts[1], 10) : null,
|
|
187
193
|
currentResX: currentResolution.length > 1 ? parseInt(currentResolution[0], 10) : null,
|
|
188
194
|
currentResY: currentResolution.length > 1 ? parseInt(currentResolution[1], 10) : null,
|
|
189
195
|
positionX: 0,
|
|
190
196
|
positionY: 0,
|
|
191
|
-
currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null
|
|
192
|
-
|
|
197
|
+
currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null
|
|
193
198
|
});
|
|
194
199
|
});
|
|
195
200
|
}
|
|
@@ -229,22 +234,26 @@ function graphics(callback) {
|
|
|
229
234
|
let i = 1;
|
|
230
235
|
lines.forEach((line) => {
|
|
231
236
|
let subsystem = '';
|
|
232
|
-
if (i < lines.length && lines[i]) {
|
|
237
|
+
if (i < lines.length && lines[i]) {
|
|
238
|
+
// get next line;
|
|
233
239
|
subsystem = lines[i];
|
|
234
240
|
if (subsystem.indexOf(':') > 0) {
|
|
235
241
|
subsystem = subsystem.split(':')[1];
|
|
236
242
|
}
|
|
237
243
|
}
|
|
238
244
|
if ('' !== line.trim()) {
|
|
239
|
-
if (' ' !== line[0] && '\t' !== line[0]) {
|
|
240
|
-
|
|
245
|
+
if (' ' !== line[0] && '\t' !== line[0]) {
|
|
246
|
+
// first line of new entry
|
|
247
|
+
let isExternal = pciIDs.indexOf(line.split(' ')[0]) >= 0;
|
|
241
248
|
let vgapos = line.toLowerCase().indexOf(' vga ');
|
|
242
249
|
let _3dcontrollerpos = line.toLowerCase().indexOf('3d controller');
|
|
243
|
-
if (vgapos !== -1 || _3dcontrollerpos !== -1) {
|
|
250
|
+
if (vgapos !== -1 || _3dcontrollerpos !== -1) {
|
|
251
|
+
// VGA
|
|
244
252
|
if (_3dcontrollerpos !== -1 && vgapos === -1) {
|
|
245
253
|
vgapos = _3dcontrollerpos;
|
|
246
254
|
}
|
|
247
|
-
if (currentController.vendor || currentController.model || currentController.bus || currentController.vram !== null || currentController.vramDynamic) {
|
|
255
|
+
if (currentController.vendor || currentController.model || currentController.bus || currentController.vram !== null || currentController.vramDynamic) {
|
|
256
|
+
// already a controller found
|
|
248
257
|
controllers.push(currentController);
|
|
249
258
|
currentController = {
|
|
250
259
|
vendor: '',
|
|
@@ -252,7 +261,7 @@ function graphics(callback) {
|
|
|
252
261
|
bus: '',
|
|
253
262
|
busAddress: '',
|
|
254
263
|
vram: null,
|
|
255
|
-
vramDynamic: false
|
|
264
|
+
vramDynamic: false
|
|
256
265
|
};
|
|
257
266
|
}
|
|
258
267
|
|
|
@@ -268,28 +277,47 @@ function graphics(callback) {
|
|
|
268
277
|
parts[1] = parts[1].trim();
|
|
269
278
|
if (parts[1].toLowerCase().indexOf('corporation') >= 0) {
|
|
270
279
|
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf('corporation') + 11).trim();
|
|
271
|
-
currentController.model = parts[1]
|
|
272
|
-
|
|
280
|
+
currentController.model = parts[1]
|
|
281
|
+
.substr(parts[1].toLowerCase().indexOf('corporation') + 11, 200)
|
|
282
|
+
.split('(')[0]
|
|
283
|
+
.trim();
|
|
284
|
+
currentController.bus = pciIDs.length > 0 && isExternal ? 'PCIe' : 'Onboard';
|
|
273
285
|
currentController.vram = null;
|
|
274
286
|
currentController.vramDynamic = false;
|
|
275
287
|
} else if (parts[1].toLowerCase().indexOf(' inc.') >= 0) {
|
|
276
288
|
if ((parts[1].match(/]/g) || []).length > 1) {
|
|
277
289
|
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(']') + 1).trim();
|
|
278
|
-
currentController.model = parts[1]
|
|
290
|
+
currentController.model = parts[1]
|
|
291
|
+
.substr(parts[1].toLowerCase().indexOf(']') + 1, 200)
|
|
292
|
+
.trim()
|
|
293
|
+
.split('(')[0]
|
|
294
|
+
.trim();
|
|
279
295
|
} else {
|
|
280
296
|
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(' inc.') + 5).trim();
|
|
281
|
-
currentController.model = parts[1]
|
|
297
|
+
currentController.model = parts[1]
|
|
298
|
+
.substr(parts[1].toLowerCase().indexOf(' inc.') + 5, 200)
|
|
299
|
+
.trim()
|
|
300
|
+
.split('(')[0]
|
|
301
|
+
.trim();
|
|
282
302
|
}
|
|
283
|
-
currentController.bus =
|
|
303
|
+
currentController.bus = pciIDs.length > 0 && isExternal ? 'PCIe' : 'Onboard';
|
|
284
304
|
currentController.vram = null;
|
|
285
305
|
currentController.vramDynamic = false;
|
|
286
306
|
} else if (parts[1].toLowerCase().indexOf(' ltd.') >= 0) {
|
|
287
307
|
if ((parts[1].match(/]/g) || []).length > 1) {
|
|
288
308
|
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(']') + 1).trim();
|
|
289
|
-
currentController.model = parts[1]
|
|
309
|
+
currentController.model = parts[1]
|
|
310
|
+
.substr(parts[1].toLowerCase().indexOf(']') + 1, 200)
|
|
311
|
+
.trim()
|
|
312
|
+
.split('(')[0]
|
|
313
|
+
.trim();
|
|
290
314
|
} else {
|
|
291
315
|
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(' ltd.') + 5).trim();
|
|
292
|
-
currentController.model = parts[1]
|
|
316
|
+
currentController.model = parts[1]
|
|
317
|
+
.substr(parts[1].toLowerCase().indexOf(' ltd.') + 5, 200)
|
|
318
|
+
.trim()
|
|
319
|
+
.split('(')[0]
|
|
320
|
+
.trim();
|
|
293
321
|
}
|
|
294
322
|
}
|
|
295
323
|
if (currentController.model && subsystem.indexOf(currentController.model) !== -1) {
|
|
@@ -299,14 +327,16 @@ function graphics(callback) {
|
|
|
299
327
|
}
|
|
300
328
|
}
|
|
301
329
|
}
|
|
302
|
-
|
|
303
330
|
} else {
|
|
304
331
|
isGraphicsController = false;
|
|
305
332
|
}
|
|
306
333
|
}
|
|
307
|
-
if (isGraphicsController) {
|
|
334
|
+
if (isGraphicsController) {
|
|
335
|
+
// within VGA details
|
|
308
336
|
let parts = line.split(':');
|
|
309
|
-
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('devicename') !== -1 && parts[1].toLowerCase().indexOf('onboard') !== -1) {
|
|
337
|
+
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('devicename') !== -1 && parts[1].toLowerCase().indexOf('onboard') !== -1) {
|
|
338
|
+
currentController.bus = 'Onboard';
|
|
339
|
+
}
|
|
310
340
|
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('region') !== -1 && parts[1].toLowerCase().indexOf('memory') !== -1) {
|
|
311
341
|
let memparts = parts[1].split('=');
|
|
312
342
|
if (memparts.length > 1) {
|
|
@@ -318,10 +348,11 @@ function graphics(callback) {
|
|
|
318
348
|
i++;
|
|
319
349
|
});
|
|
320
350
|
|
|
321
|
-
if (currentController.vendor || currentController.model || currentController.bus || currentController.busAddress || currentController.vram !== null || currentController.vramDynamic) {
|
|
351
|
+
if (currentController.vendor || currentController.model || currentController.bus || currentController.busAddress || currentController.vram !== null || currentController.vramDynamic) {
|
|
352
|
+
// already a controller found
|
|
322
353
|
controllers.push(currentController);
|
|
323
354
|
}
|
|
324
|
-
return
|
|
355
|
+
return controllers;
|
|
325
356
|
}
|
|
326
357
|
|
|
327
358
|
function parseLinesLinuxClinfo(controllers, lines) {
|
|
@@ -356,7 +387,7 @@ function graphics(callback) {
|
|
|
356
387
|
}
|
|
357
388
|
}
|
|
358
389
|
if (busAddress) {
|
|
359
|
-
let controller = controllers.find(controller => controller.busAddress === busAddress);
|
|
390
|
+
let controller = controllers.find((controller) => controller.busAddress === busAddress);
|
|
360
391
|
if (!controller) {
|
|
361
392
|
controller = {
|
|
362
393
|
vendor: '',
|
|
@@ -391,22 +422,27 @@ function graphics(callback) {
|
|
|
391
422
|
|
|
392
423
|
if (_windows) {
|
|
393
424
|
try {
|
|
394
|
-
const basePath = util.WINDIR +
|
|
425
|
+
const basePath = util.WINDIR + String.raw`\System32\DriverStore\FileRepository`;
|
|
395
426
|
// find all directories that have an nvidia-smi.exe file
|
|
396
|
-
|
|
397
|
-
|
|
427
|
+
|
|
428
|
+
const candidateDirs = fs.readdirSync(basePath).filter((dir) => {
|
|
429
|
+
if (fs.statSync([basePath, dir].join('/')).isDirectory()) {
|
|
430
|
+
return fs.readdirSync([basePath, dir].join('/')).includes('nvidia-smi.exe');
|
|
431
|
+
} else {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
398
434
|
});
|
|
399
435
|
// use the directory with the most recently created nvidia-smi.exe file
|
|
400
436
|
const targetDir = candidateDirs.reduce((prevDir, currentDir) => {
|
|
401
437
|
const previousNvidiaSmi = fs.statSync([basePath, prevDir, 'nvidia-smi.exe'].join('/'));
|
|
402
438
|
const currentNvidiaSmi = fs.statSync([basePath, currentDir, 'nvidia-smi.exe'].join('/'));
|
|
403
|
-
return
|
|
439
|
+
return previousNvidiaSmi.ctimeMs > currentNvidiaSmi.ctimeMs ? prevDir : currentDir;
|
|
404
440
|
});
|
|
405
441
|
|
|
406
442
|
if (targetDir) {
|
|
407
443
|
_nvidiaSmiPath = [basePath, targetDir, 'nvidia-smi.exe'].join('/');
|
|
408
444
|
}
|
|
409
|
-
} catch
|
|
445
|
+
} catch {
|
|
410
446
|
util.noop();
|
|
411
447
|
}
|
|
412
448
|
} else if (_linux) {
|
|
@@ -419,16 +455,17 @@ function graphics(callback) {
|
|
|
419
455
|
const nvidiaSmiExe = getNvidiaSmi();
|
|
420
456
|
options = options || util.execOptsWin;
|
|
421
457
|
if (nvidiaSmiExe) {
|
|
422
|
-
const nvidiaSmiOpts =
|
|
423
|
-
|
|
458
|
+
const nvidiaSmiOpts =
|
|
459
|
+
'--query-gpu=driver_version,pci.sub_device_id,name,pci.bus_id,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,temperature.memory,power.draw,power.limit,clocks.gr,clocks.mem --format=csv,noheader,nounits';
|
|
460
|
+
const cmd = nvidiaSmiExe + ' ' + nvidiaSmiOpts;
|
|
424
461
|
if (_linux) {
|
|
425
462
|
options.stdio = ['pipe', 'pipe', 'ignore'];
|
|
426
463
|
}
|
|
427
464
|
try {
|
|
428
|
-
const sanitized = util.sanitizeShellString(cmd);
|
|
465
|
+
const sanitized = util.sanitizeShellString(cmd) + (_linux ? ' 2>/dev/null' : '');
|
|
429
466
|
const res = execSync(sanitized, options).toString();
|
|
430
467
|
return res;
|
|
431
|
-
} catch
|
|
468
|
+
} catch {
|
|
432
469
|
util.noop();
|
|
433
470
|
}
|
|
434
471
|
}
|
|
@@ -436,7 +473,6 @@ function graphics(callback) {
|
|
|
436
473
|
}
|
|
437
474
|
|
|
438
475
|
function nvidiaDevices() {
|
|
439
|
-
|
|
440
476
|
function safeParseNumber(value) {
|
|
441
477
|
if ([null, undefined].includes(value)) {
|
|
442
478
|
return value;
|
|
@@ -450,8 +486,8 @@ function graphics(callback) {
|
|
|
450
486
|
}
|
|
451
487
|
|
|
452
488
|
const gpus = stdout.split('\n').filter(Boolean);
|
|
453
|
-
let results = gpus.map(gpu => {
|
|
454
|
-
const splittedData = gpu.split(', ').map(value => value.includes('N/A') ? undefined : value);
|
|
489
|
+
let results = gpus.map((gpu) => {
|
|
490
|
+
const splittedData = gpu.split(', ').map((value) => (value.includes('N/A') ? undefined : value));
|
|
455
491
|
if (splittedData.length === 16) {
|
|
456
492
|
return {
|
|
457
493
|
driverVersion: splittedData[0],
|
|
@@ -469,39 +505,69 @@ function graphics(callback) {
|
|
|
469
505
|
powerDraw: safeParseNumber(splittedData[12]),
|
|
470
506
|
powerLimit: safeParseNumber(splittedData[13]),
|
|
471
507
|
clockCore: safeParseNumber(splittedData[14]),
|
|
472
|
-
clockMemory: safeParseNumber(splittedData[15])
|
|
508
|
+
clockMemory: safeParseNumber(splittedData[15])
|
|
473
509
|
};
|
|
474
510
|
} else {
|
|
475
511
|
return {};
|
|
476
512
|
}
|
|
477
513
|
});
|
|
478
514
|
results = results.filter((item) => {
|
|
479
|
-
return
|
|
515
|
+
return 'pciBus' in item;
|
|
480
516
|
});
|
|
481
517
|
return results;
|
|
482
518
|
}
|
|
483
519
|
|
|
484
520
|
function mergeControllerNvidia(controller, nvidia) {
|
|
485
|
-
if (nvidia.driverVersion) {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (nvidia.
|
|
489
|
-
|
|
521
|
+
if (nvidia.driverVersion) {
|
|
522
|
+
controller.driverVersion = nvidia.driverVersion;
|
|
523
|
+
}
|
|
524
|
+
if (nvidia.subDeviceId) {
|
|
525
|
+
controller.subDeviceId = nvidia.subDeviceId;
|
|
526
|
+
}
|
|
527
|
+
if (nvidia.name) {
|
|
528
|
+
controller.name = nvidia.name;
|
|
529
|
+
}
|
|
530
|
+
if (nvidia.pciBus) {
|
|
531
|
+
controller.pciBus = nvidia.pciBus;
|
|
532
|
+
}
|
|
533
|
+
if (nvidia.fanSpeed) {
|
|
534
|
+
controller.fanSpeed = nvidia.fanSpeed;
|
|
535
|
+
}
|
|
490
536
|
if (nvidia.memoryTotal) {
|
|
491
537
|
controller.memoryTotal = nvidia.memoryTotal;
|
|
492
538
|
controller.vram = nvidia.memoryTotal;
|
|
493
539
|
controller.vramDynamic = false;
|
|
494
540
|
}
|
|
495
|
-
if (nvidia.memoryUsed) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (nvidia.
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (nvidia.
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (nvidia.
|
|
541
|
+
if (nvidia.memoryUsed) {
|
|
542
|
+
controller.memoryUsed = nvidia.memoryUsed;
|
|
543
|
+
}
|
|
544
|
+
if (nvidia.memoryFree) {
|
|
545
|
+
controller.memoryFree = nvidia.memoryFree;
|
|
546
|
+
}
|
|
547
|
+
if (nvidia.utilizationGpu) {
|
|
548
|
+
controller.utilizationGpu = nvidia.utilizationGpu;
|
|
549
|
+
}
|
|
550
|
+
if (nvidia.utilizationMemory) {
|
|
551
|
+
controller.utilizationMemory = nvidia.utilizationMemory;
|
|
552
|
+
}
|
|
553
|
+
if (nvidia.temperatureGpu) {
|
|
554
|
+
controller.temperatureGpu = nvidia.temperatureGpu;
|
|
555
|
+
}
|
|
556
|
+
if (nvidia.temperatureMemory) {
|
|
557
|
+
controller.temperatureMemory = nvidia.temperatureMemory;
|
|
558
|
+
}
|
|
559
|
+
if (nvidia.powerDraw) {
|
|
560
|
+
controller.powerDraw = nvidia.powerDraw;
|
|
561
|
+
}
|
|
562
|
+
if (nvidia.powerLimit) {
|
|
563
|
+
controller.powerLimit = nvidia.powerLimit;
|
|
564
|
+
}
|
|
565
|
+
if (nvidia.clockCore) {
|
|
566
|
+
controller.clockCore = nvidia.clockCore;
|
|
567
|
+
}
|
|
568
|
+
if (nvidia.clockMemory) {
|
|
569
|
+
controller.clockMemory = nvidia.clockMemory;
|
|
570
|
+
}
|
|
505
571
|
return controller;
|
|
506
572
|
}
|
|
507
573
|
|
|
@@ -514,7 +580,7 @@ function graphics(callback) {
|
|
|
514
580
|
// --> pixeldepth (?)
|
|
515
581
|
// --> sizex
|
|
516
582
|
// --> sizey
|
|
517
|
-
|
|
583
|
+
const result = {
|
|
518
584
|
vendor: '',
|
|
519
585
|
model: '',
|
|
520
586
|
deviceName: '',
|
|
@@ -559,11 +625,12 @@ function graphics(callback) {
|
|
|
559
625
|
}
|
|
560
626
|
try {
|
|
561
627
|
if (model_raw.length > 2) {
|
|
562
|
-
result.model = model_raw
|
|
563
|
-
|
|
564
|
-
|
|
628
|
+
result.model = model_raw
|
|
629
|
+
.match(/.{1,2}/g)
|
|
630
|
+
.map((v) => String.fromCharCode(parseInt(v, 16)))
|
|
631
|
+
.join('');
|
|
565
632
|
}
|
|
566
|
-
} catch
|
|
633
|
+
} catch {
|
|
567
634
|
util.noop();
|
|
568
635
|
}
|
|
569
636
|
} else {
|
|
@@ -573,7 +640,7 @@ function graphics(callback) {
|
|
|
573
640
|
}
|
|
574
641
|
|
|
575
642
|
function parseLinesLinuxDisplays(lines, depth) {
|
|
576
|
-
|
|
643
|
+
const displays = [];
|
|
577
644
|
let currentDisplay = {
|
|
578
645
|
vendor: '',
|
|
579
646
|
model: '',
|
|
@@ -596,10 +663,21 @@ function graphics(callback) {
|
|
|
596
663
|
let is_current = false;
|
|
597
664
|
let edid_raw = '';
|
|
598
665
|
let start = 0;
|
|
599
|
-
for (let i = 1; i < lines.length; i++) {
|
|
666
|
+
for (let i = 1; i < lines.length; i++) {
|
|
667
|
+
// start with second line
|
|
600
668
|
if ('' !== lines[i].trim()) {
|
|
601
|
-
if (' ' !== lines[i][0] && '\t' !== lines[i][0] && lines[i].toLowerCase().indexOf(' connected ') !== -1) {
|
|
602
|
-
|
|
669
|
+
if (' ' !== lines[i][0] && '\t' !== lines[i][0] && lines[i].toLowerCase().indexOf(' connected ') !== -1) {
|
|
670
|
+
// first line of new entry
|
|
671
|
+
if (
|
|
672
|
+
currentDisplay.model ||
|
|
673
|
+
currentDisplay.main ||
|
|
674
|
+
currentDisplay.builtin ||
|
|
675
|
+
currentDisplay.connection ||
|
|
676
|
+
currentDisplay.sizeX !== null ||
|
|
677
|
+
currentDisplay.pixelDepth !== null ||
|
|
678
|
+
currentDisplay.resolutionX !== null
|
|
679
|
+
) {
|
|
680
|
+
// push last display to array
|
|
603
681
|
displays.push(currentDisplay);
|
|
604
682
|
currentDisplay = {
|
|
605
683
|
vendor: '',
|
|
@@ -622,7 +700,7 @@ function graphics(callback) {
|
|
|
622
700
|
let parts = lines[i].split(' ');
|
|
623
701
|
currentDisplay.connection = parts[0];
|
|
624
702
|
currentDisplay.main = lines[i].toLowerCase().indexOf(' primary ') >= 0;
|
|
625
|
-
currentDisplay.builtin =
|
|
703
|
+
currentDisplay.builtin = parts[0].toLowerCase().indexOf('edp') >= 0;
|
|
626
704
|
}
|
|
627
705
|
|
|
628
706
|
// try to read EDID information
|
|
@@ -666,7 +744,16 @@ function graphics(callback) {
|
|
|
666
744
|
}
|
|
667
745
|
|
|
668
746
|
// pushen displays
|
|
669
|
-
if (
|
|
747
|
+
if (
|
|
748
|
+
currentDisplay.model ||
|
|
749
|
+
currentDisplay.main ||
|
|
750
|
+
currentDisplay.builtin ||
|
|
751
|
+
currentDisplay.connection ||
|
|
752
|
+
currentDisplay.sizeX !== null ||
|
|
753
|
+
currentDisplay.pixelDepth !== null ||
|
|
754
|
+
currentDisplay.resolutionX !== null
|
|
755
|
+
) {
|
|
756
|
+
// still information there
|
|
670
757
|
displays.push(currentDisplay);
|
|
671
758
|
}
|
|
672
759
|
return displays;
|
|
@@ -680,8 +767,8 @@ function graphics(callback) {
|
|
|
680
767
|
displays: []
|
|
681
768
|
};
|
|
682
769
|
if (_darwin) {
|
|
683
|
-
|
|
684
|
-
exec(cmd,
|
|
770
|
+
const cmd = 'system_profiler -xml -detailLevel full SPDisplaysDataType';
|
|
771
|
+
exec(cmd, (error, stdout) => {
|
|
685
772
|
if (!error) {
|
|
686
773
|
try {
|
|
687
774
|
const output = stdout.toString();
|
|
@@ -690,7 +777,10 @@ function graphics(callback) {
|
|
|
690
777
|
util.noop();
|
|
691
778
|
}
|
|
692
779
|
try {
|
|
693
|
-
stdout = execSync(
|
|
780
|
+
stdout = execSync(
|
|
781
|
+
'defaults read /Library/Preferences/com.apple.windowserver.plist 2>/dev/null;defaults read /Library/Preferences/com.apple.windowserver.displays.plist 2>/dev/null; echo ""',
|
|
782
|
+
{ maxBuffer: 1024 * 20000 }
|
|
783
|
+
);
|
|
694
784
|
const output = (stdout || '').toString();
|
|
695
785
|
const obj = util.plistReader(output);
|
|
696
786
|
if (obj['DisplayAnyUserSets'] && obj['DisplayAnyUserSets']['Configs'] && obj['DisplayAnyUserSets']['Configs'][0] && obj['DisplayAnyUserSets']['Configs'][0]['DisplayConfig']) {
|
|
@@ -722,7 +812,7 @@ function graphics(callback) {
|
|
|
722
812
|
i++;
|
|
723
813
|
});
|
|
724
814
|
}
|
|
725
|
-
} catch
|
|
815
|
+
} catch {
|
|
726
816
|
util.noop();
|
|
727
817
|
}
|
|
728
818
|
}
|
|
@@ -735,9 +825,9 @@ function graphics(callback) {
|
|
|
735
825
|
if (_linux) {
|
|
736
826
|
// Raspberry: https://elinux.org/RPI_vcgencmd_usage
|
|
737
827
|
if (util.isRaspberry()) {
|
|
738
|
-
|
|
739
|
-
exec(cmd,
|
|
740
|
-
|
|
828
|
+
const cmd = "fbset -s 2> /dev/null | grep 'mode \"' ; vcgencmd get_mem gpu 2> /dev/null; tvservice -s 2> /dev/null; tvservice -n 2> /dev/null;";
|
|
829
|
+
exec(cmd, (error, stdout) => {
|
|
830
|
+
const lines = stdout.toString().split('\n');
|
|
741
831
|
if (lines.length > 3 && lines[0].indexOf('mode "') >= -1 && lines[2].indexOf('0x12000a') > -1) {
|
|
742
832
|
const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
|
|
743
833
|
if (parts.length === 2) {
|
|
@@ -769,44 +859,41 @@ function graphics(callback) {
|
|
|
769
859
|
vramDynamic: true
|
|
770
860
|
});
|
|
771
861
|
}
|
|
772
|
-
// if (callback) {
|
|
773
|
-
// callback(result);
|
|
774
|
-
// }
|
|
775
|
-
// resolve(result);
|
|
776
862
|
});
|
|
777
863
|
}
|
|
778
864
|
// } else {
|
|
779
|
-
|
|
780
|
-
exec(cmd,
|
|
865
|
+
const cmd = 'lspci -vvv 2>/dev/null';
|
|
866
|
+
exec(cmd, (error, stdout) => {
|
|
781
867
|
if (!error) {
|
|
782
|
-
|
|
868
|
+
const lines = stdout.toString().split('\n');
|
|
783
869
|
if (result.controllers.length === 0) {
|
|
784
870
|
result.controllers = parseLinesLinuxControllers(lines);
|
|
785
871
|
|
|
786
872
|
const nvidiaData = nvidiaDevices();
|
|
787
873
|
// needs to be rewritten ... using no spread operators
|
|
788
|
-
result.controllers = result.controllers.map((controller) => {
|
|
874
|
+
result.controllers = result.controllers.map((controller) => {
|
|
875
|
+
// match by busAddress
|
|
789
876
|
return mergeControllerNvidia(controller, nvidiaData.find((contr) => contr.pciBus.toLowerCase().endsWith(controller.busAddress.toLowerCase())) || {});
|
|
790
877
|
});
|
|
791
878
|
}
|
|
792
879
|
}
|
|
793
|
-
|
|
794
|
-
exec(cmd,
|
|
880
|
+
const cmd = 'clinfo --raw';
|
|
881
|
+
exec(cmd, (error, stdout) => {
|
|
795
882
|
if (!error) {
|
|
796
|
-
|
|
883
|
+
const lines = stdout.toString().split('\n');
|
|
797
884
|
result.controllers = parseLinesLinuxClinfo(result.controllers, lines);
|
|
798
885
|
}
|
|
799
|
-
|
|
800
|
-
exec(cmd,
|
|
886
|
+
const cmd = "xdpyinfo 2>/dev/null | grep 'depth of root window' | awk '{ print $5 }'";
|
|
887
|
+
exec(cmd, (error, stdout) => {
|
|
801
888
|
let depth = 0;
|
|
802
889
|
if (!error) {
|
|
803
|
-
|
|
890
|
+
const lines = stdout.toString().split('\n');
|
|
804
891
|
depth = parseInt(lines[0]) || 0;
|
|
805
892
|
}
|
|
806
|
-
|
|
807
|
-
exec(cmd,
|
|
893
|
+
const cmd = 'xrandr --verbose 2>/dev/null';
|
|
894
|
+
exec(cmd, (error, stdout) => {
|
|
808
895
|
if (!error) {
|
|
809
|
-
|
|
896
|
+
const lines = stdout.toString().split('\n');
|
|
810
897
|
result.displays = parseLinesLinuxDisplays(lines, depth);
|
|
811
898
|
}
|
|
812
899
|
if (callback) {
|
|
@@ -820,124 +907,142 @@ function graphics(callback) {
|
|
|
820
907
|
// }
|
|
821
908
|
}
|
|
822
909
|
if (_freebsd || _openbsd || _netbsd) {
|
|
823
|
-
if (callback) {
|
|
910
|
+
if (callback) {
|
|
911
|
+
callback(null);
|
|
912
|
+
}
|
|
824
913
|
resolve(null);
|
|
825
914
|
}
|
|
826
915
|
if (_sunos) {
|
|
827
|
-
if (callback) {
|
|
916
|
+
if (callback) {
|
|
917
|
+
callback(null);
|
|
918
|
+
}
|
|
828
919
|
resolve(null);
|
|
829
920
|
}
|
|
830
921
|
if (_windows) {
|
|
831
|
-
|
|
832
922
|
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
|
833
923
|
// https://devblogs.microsoft.com/scripting/use-powershell-to-discover-multi-monitor-information/
|
|
834
924
|
try {
|
|
835
925
|
const workload = [];
|
|
836
926
|
workload.push(util.powerShell('Get-CimInstance win32_VideoController | fl *'));
|
|
837
|
-
workload.push(
|
|
927
|
+
workload.push(
|
|
928
|
+
util.powerShell(
|
|
929
|
+
'gp "HKLM:\\SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\*" -ErrorAction SilentlyContinue | where MatchingDeviceId $null -NE | select MatchingDeviceId,HardwareInformation.qwMemorySize | fl'
|
|
930
|
+
)
|
|
931
|
+
);
|
|
838
932
|
workload.push(util.powerShell('Get-CimInstance win32_desktopmonitor | fl *'));
|
|
839
933
|
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
|
|
840
934
|
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
|
|
841
935
|
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
|
|
842
|
-
workload.push(
|
|
936
|
+
workload.push(
|
|
937
|
+
util.powerShell(
|
|
938
|
+
'gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.InstanceName}'
|
|
939
|
+
)
|
|
940
|
+
);
|
|
843
941
|
|
|
844
942
|
const nvidiaData = nvidiaDevices();
|
|
845
943
|
|
|
846
|
-
Promise.all(
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
windowsSubDeviceId
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
944
|
+
Promise.all(workload)
|
|
945
|
+
.then((data) => {
|
|
946
|
+
// controller + vram
|
|
947
|
+
const csections = data[0].replace(/\r/g, '').split(/\n\s*\n/);
|
|
948
|
+
const vsections = data[1].replace(/\r/g, '').split(/\n\s*\n/);
|
|
949
|
+
result.controllers = parseLinesWindowsControllers(csections, vsections);
|
|
950
|
+
result.controllers = result.controllers.map((controller) => {
|
|
951
|
+
// match by subDeviceId
|
|
952
|
+
if (controller.vendor.toLowerCase() === 'nvidia') {
|
|
953
|
+
return mergeControllerNvidia(
|
|
954
|
+
controller,
|
|
955
|
+
nvidiaData.find((device) => {
|
|
956
|
+
let windowsSubDeviceId = (controller.subDeviceId || '').toLowerCase();
|
|
957
|
+
const nvidiaSubDeviceIdParts = device.subDeviceId.split('x');
|
|
958
|
+
let nvidiaSubDeviceId = nvidiaSubDeviceIdParts.length > 1 ? nvidiaSubDeviceIdParts[1].toLowerCase() : nvidiaSubDeviceIdParts[0].toLowerCase();
|
|
959
|
+
const lengthDifference = Math.abs(windowsSubDeviceId.length - nvidiaSubDeviceId.length);
|
|
960
|
+
if (windowsSubDeviceId.length > nvidiaSubDeviceId.length) {
|
|
961
|
+
for (let i = 0; i < lengthDifference; i++) {
|
|
962
|
+
nvidiaSubDeviceId = '0' + nvidiaSubDeviceId;
|
|
963
|
+
}
|
|
964
|
+
} else if (windowsSubDeviceId.length < nvidiaSubDeviceId.length) {
|
|
965
|
+
for (let i = 0; i < lengthDifference; i++) {
|
|
966
|
+
windowsSubDeviceId = '0' + windowsSubDeviceId;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return windowsSubDeviceId === nvidiaSubDeviceId;
|
|
970
|
+
}) || {}
|
|
971
|
+
);
|
|
972
|
+
} else {
|
|
973
|
+
return controller;
|
|
974
|
+
}
|
|
975
|
+
});
|
|
875
976
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
977
|
+
// displays
|
|
978
|
+
const dsections = data[2].replace(/\r/g, '').split(/\n\s*\n/);
|
|
979
|
+
// result.displays = parseLinesWindowsDisplays(dsections);
|
|
980
|
+
if (dsections[0].trim() === '') {
|
|
981
|
+
dsections.shift();
|
|
982
|
+
}
|
|
983
|
+
if (dsections.length && dsections[dsections.length - 1].trim() === '') {
|
|
984
|
+
dsections.pop();
|
|
985
|
+
}
|
|
881
986
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
987
|
+
// monitor (powershell)
|
|
988
|
+
const msections = data[3].replace(/\r/g, '').split('Active ');
|
|
989
|
+
msections.shift();
|
|
885
990
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
991
|
+
// forms.screens (powershell)
|
|
992
|
+
const ssections = data[4].replace(/\r/g, '').split('BitsPerPixel ');
|
|
993
|
+
ssections.shift();
|
|
889
994
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
995
|
+
// connection params (powershell) - video type
|
|
996
|
+
const tsections = data[5].replace(/\r/g, '').split(/\n\s*\n/);
|
|
997
|
+
tsections.shift();
|
|
893
998
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
999
|
+
// monitor ID (powershell) - model / vendor
|
|
1000
|
+
const res = data[6].replace(/\r/g, '').split(/\n/);
|
|
1001
|
+
const isections = [];
|
|
1002
|
+
res.forEach((element) => {
|
|
1003
|
+
const parts = element.split('|');
|
|
1004
|
+
if (parts.length === 5) {
|
|
1005
|
+
isections.push({
|
|
1006
|
+
vendor: parts[0],
|
|
1007
|
+
code: parts[1],
|
|
1008
|
+
model: parts[2],
|
|
1009
|
+
serial: parts[3],
|
|
1010
|
+
instanceId: parts[4]
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
909
1014
|
|
|
910
|
-
|
|
1015
|
+
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
|
|
911
1016
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1017
|
+
if (result.displays.length === 1) {
|
|
1018
|
+
if (_resolutionX) {
|
|
1019
|
+
result.displays[0].resolutionX = _resolutionX;
|
|
1020
|
+
if (!result.displays[0].currentResX) {
|
|
1021
|
+
result.displays[0].currentResX = _resolutionX;
|
|
1022
|
+
}
|
|
917
1023
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1024
|
+
if (_resolutionY) {
|
|
1025
|
+
result.displays[0].resolutionY = _resolutionY;
|
|
1026
|
+
if (result.displays[0].currentResY === 0) {
|
|
1027
|
+
result.displays[0].currentResY = _resolutionY;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
if (_pixelDepth) {
|
|
1031
|
+
result.displays[0].pixelDepth = _pixelDepth;
|
|
923
1032
|
}
|
|
924
1033
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
element.currentRefreshRate = _refreshRate;
|
|
932
|
-
}
|
|
933
|
-
return element;
|
|
934
|
-
});
|
|
1034
|
+
result.displays = result.displays.map((element) => {
|
|
1035
|
+
if (_refreshRate && !element.currentRefreshRate) {
|
|
1036
|
+
element.currentRefreshRate = _refreshRate;
|
|
1037
|
+
}
|
|
1038
|
+
return element;
|
|
1039
|
+
});
|
|
935
1040
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1041
|
+
if (callback) {
|
|
1042
|
+
callback(result);
|
|
1043
|
+
}
|
|
1044
|
+
resolve(result);
|
|
1045
|
+
})
|
|
941
1046
|
.catch(() => {
|
|
942
1047
|
if (callback) {
|
|
943
1048
|
callback(result);
|
|
@@ -945,7 +1050,9 @@ function graphics(callback) {
|
|
|
945
1050
|
resolve(result);
|
|
946
1051
|
});
|
|
947
1052
|
} catch (e) {
|
|
948
|
-
if (callback) {
|
|
1053
|
+
if (callback) {
|
|
1054
|
+
callback(result);
|
|
1055
|
+
}
|
|
949
1056
|
resolve(result);
|
|
950
1057
|
}
|
|
951
1058
|
}
|
|
@@ -976,12 +1083,12 @@ function graphics(callback) {
|
|
|
976
1083
|
}
|
|
977
1084
|
}
|
|
978
1085
|
|
|
979
|
-
|
|
980
|
-
for (
|
|
1086
|
+
const controllers = [];
|
|
1087
|
+
for (const i in sections) {
|
|
981
1088
|
if ({}.hasOwnProperty.call(sections, i)) {
|
|
982
1089
|
if (sections[i].trim() !== '') {
|
|
983
|
-
|
|
984
|
-
|
|
1090
|
+
const lines = sections[i].trim().split('\n');
|
|
1091
|
+
const pnpDeviceId = util.getValue(lines, 'PNPDeviceID', ':').match(/PCI\\(VEN_[0-9A-F]{4})&(DEV_[0-9A-F]{4})(?:&(SUBSYS_[0-9A-F]{8}))?(?:&(REV_[0-9A-F]{2}))?/i);
|
|
985
1092
|
let subDeviceId = null;
|
|
986
1093
|
let memorySize = null;
|
|
987
1094
|
if (pnpDeviceId) {
|
|
@@ -1031,7 +1138,7 @@ function graphics(callback) {
|
|
|
1031
1138
|
model: util.getValue(lines, 'name', ':'),
|
|
1032
1139
|
bus: util.getValue(lines, 'PNPDeviceID', ':').startsWith('PCI') ? 'PCI' : '',
|
|
1033
1140
|
vram: (memorySize == null ? util.toInt(util.getValue(lines, 'AdapterRAM', ':')) : memorySize) / 1024 / 1024,
|
|
1034
|
-
vramDynamic:
|
|
1141
|
+
vramDynamic: util.getValue(lines, 'VideoMemoryType', ':') === '2',
|
|
1035
1142
|
subDeviceId
|
|
1036
1143
|
});
|
|
1037
1144
|
_resolutionX = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', ':')) || _resolutionX;
|
|
@@ -1045,14 +1152,14 @@ function graphics(callback) {
|
|
|
1045
1152
|
}
|
|
1046
1153
|
|
|
1047
1154
|
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections) {
|
|
1048
|
-
|
|
1155
|
+
const displays = [];
|
|
1049
1156
|
let vendor = '';
|
|
1050
1157
|
let model = '';
|
|
1051
1158
|
let deviceID = '';
|
|
1052
1159
|
let resolutionX = 0;
|
|
1053
1160
|
let resolutionY = 0;
|
|
1054
1161
|
if (dsections && dsections.length) {
|
|
1055
|
-
|
|
1162
|
+
const linesDisplay = dsections[0].split('\n');
|
|
1056
1163
|
vendor = util.getValue(linesDisplay, 'MonitorManufacturer', ':');
|
|
1057
1164
|
model = util.getValue(linesDisplay, 'Name', ':');
|
|
1058
1165
|
deviceID = util.getValue(linesDisplay, 'PNPDeviceID', ':').replace(/&/g, '&').toLowerCase();
|
|
@@ -1068,10 +1175,10 @@ function graphics(callback) {
|
|
|
1068
1175
|
if (tsections.length === 0 || tsections[i] === undefined) {
|
|
1069
1176
|
tsections[i] = 'Unknown';
|
|
1070
1177
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1178
|
+
const linesScreen = ssections[i].split('\n');
|
|
1179
|
+
const linesMonitor = msections[i].split('\n');
|
|
1073
1180
|
|
|
1074
|
-
|
|
1181
|
+
const linesConnection = tsections[i].split('\n');
|
|
1075
1182
|
const bitsPerPixel = util.getValue(linesScreen, 'BitsPerPixel');
|
|
1076
1183
|
const bounds = util.getValue(linesScreen, 'Bounds').replace('{', '').replace('}', '').replace(/=/g, ':').split(',');
|
|
1077
1184
|
const primary = util.getValue(linesScreen, 'Primary');
|
|
@@ -1082,7 +1189,7 @@ function graphics(callback) {
|
|
|
1082
1189
|
const deviceName = util.getValue(linesScreen, 'DeviceName');
|
|
1083
1190
|
let displayVendor = '';
|
|
1084
1191
|
let displayModel = '';
|
|
1085
|
-
isections.forEach(element => {
|
|
1192
|
+
isections.forEach((element) => {
|
|
1086
1193
|
if (element.instanceId.toLowerCase().startsWith(instanceName) && vendor.startsWith('(') && model.startsWith('PnP')) {
|
|
1087
1194
|
displayVendor = element.vendor;
|
|
1088
1195
|
displayModel = element.model;
|
|
@@ -1103,7 +1210,7 @@ function graphics(callback) {
|
|
|
1103
1210
|
currentResX: util.toInt(util.getValue(bounds, 'Width', ':')),
|
|
1104
1211
|
currentResY: util.toInt(util.getValue(bounds, 'Height', ':')),
|
|
1105
1212
|
positionX: util.toInt(util.getValue(bounds, 'X', ':')),
|
|
1106
|
-
positionY: util.toInt(util.getValue(bounds, 'Y', ':'))
|
|
1213
|
+
positionY: util.toInt(util.getValue(bounds, 'Y', ':'))
|
|
1107
1214
|
});
|
|
1108
1215
|
}
|
|
1109
1216
|
}
|