Skip to content

Commit

Permalink
feat: read GPUs on OS X
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
Kaixhin committed Jan 11, 2016
1 parent a788d27 commit 7c3b87a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,21 @@ fs.readFile("specs.json", "utf-8")
gpus: []
};
// GPU models
if (os.platform() === 'linux') {
if (os.platform() === "linux") {
var lspci = spawnSync("lspci", []);
var grep = spawnSync("grep", ["-i", "vga"], {input: lspci.stdout});
var gpuStrings = grep.stdout.toString().split("\n");
for (var i = 0; i < gpuStrings.length - 1; i++) {
specs.gpus.push(gpuStrings[i].replace(/.*controller: /g, ""));
}
} else if (os.platform() === "darwin") {
var system_profiler = spawnSync("system_profiler", ["SPDisplaysDataType"]);
var profilerStrings = system_profiler.stdout.toString().split("\n");
for (var i = 0; i < profilerStrings.length - 1; i++) {
if (profilerStrings[i].indexOf("Chipset Model:") > -1) {
specs.gpus.push(profilerStrings[i].replace(/Chipset Model: /g, ""));
}
}
}

// Register details
Expand Down

0 comments on commit 7c3b87a

Please sign in to comment.