Skip to content

Commit

Permalink
graphics() improve vendor parsing (linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Aug 25, 2023
1 parent 6d06d62 commit fc06a0e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit fc06a0e

Please sign in to comment.