graphics() improve vendor parsing (linux)

This commit is contained in:
Sebastian Hildebrandt 2023-08-25 08:14:24 +02:00
parent 6d06d62ecc
commit fc06a0e671

View File

@ -225,7 +225,10 @@ function graphics(callback) {
} catch (e) {
util.noop();
}
let i = 1;
lines.forEach((line) => {
let subsystem = '';
if (i < lines.length && lines[i]) { subsystem = lines[i]; } // get next line;
if ('' !== line.trim()) {
if (' ' !== line[0] && '\t' !== line[0]) { // first line of new entry
let isExternal = (pciIDs.indexOf(line.split(' ')[0]) >= 0);
@ -259,7 +262,7 @@ function graphics(callback) {
parts[1] = parts[1].trim();
if (parts[1].toLowerCase().indexOf('corporation') >= 0) {
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf('corporation') + 11).trim();
currentController.model = parts[1].substr(parts[1].toLowerCase().indexOf('corporation') + 11, 200).trim().split('(')[0];
currentController.model = parts[1].substr(parts[1].toLowerCase().indexOf('corporation') + 11, 200).split('(')[0].trim();
currentController.bus = (pciIDs.length > 0 && isExternal) ? 'PCIe' : 'Onboard';
currentController.vram = null;
currentController.vramDynamic = false;
@ -283,6 +286,12 @@ function graphics(callback) {
currentController.model = parts[1].substr(parts[1].toLowerCase().indexOf(' ltd.') + 5, 200).trim().split('(')[0].trim();
}
}
if (currentController.model && subsystem.indexOf(currentController.model) !== -1) {
const vendor2 = subsystem.split(currentController.model)[0].trim();
if (vendor2) {
currentController.vendor += ', ' + vendor2;
}
}
}
} else {
@ -300,6 +309,7 @@ function graphics(callback) {
}
}
}
i++;
});
if (currentController.vendor || currentController.model || currentController.bus || currentController.busAddress || currentController.vram !== null || currentController.vramDynamic) { // already a controller found