graphics() added display vendor, refresh rate
This commit is contained in:
parent
2d3f674201
commit
83f1902a8e
@ -251,8 +251,9 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
|||||||
| | ...[0].bus | X | | X | X | | on which bus (e.g. PCIe) |
|
| | ...[0].bus | X | | X | X | | on which bus (e.g. PCIe) |
|
||||||
| | ...[0].vram | X | | X | X | | VRAM size (in MB) |
|
| | ...[0].vram | X | | X | X | | VRAM size (in MB) |
|
||||||
| | ...[0].vramDynamic | X | | X | X | | true if dynamicly allocated ram |
|
| | ...[0].vramDynamic | X | | X | X | | true if dynamicly allocated ram |
|
||||||
| | displays[] | X | | X | X | | monitor/display Array |
|
| | displays[] | X | | X | X | | monitor/display array |
|
||||||
| | ...[0].model | X | | X | X | | monitor/display Model |
|
| | ...[0].vendor | | | X | | | monitor/display vendor |
|
||||||
|
| | ...[0].model | X | | X | X | | monitor/display model |
|
||||||
| | ...[0].main | X | | X | | | true if main monitor |
|
| | ...[0].main | X | | X | | | true if main monitor |
|
||||||
| | ...[0].builtin | X | | X | | | true if built in monitor |
|
| | ...[0].builtin | X | | X | | | true if built in monitor |
|
||||||
| | ...[0].connection | X | | X | | | e.g. DisplayPort or HDMI |
|
| | ...[0].connection | X | | X | | | e.g. DisplayPort or HDMI |
|
||||||
@ -261,6 +262,9 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
|||||||
| | ...[0].pixeldepth | X | | X | X | | color depth in bits |
|
| | ...[0].pixeldepth | X | | X | X | | color depth in bits |
|
||||||
| | ...[0].resolutionx | X | | X | X | | pixel horizontal |
|
| | ...[0].resolutionx | X | | X | X | | pixel horizontal |
|
||||||
| | ...[0].resolutiony | X | | X | X | | pixel vertical |
|
| | ...[0].resolutiony | X | | X | X | | pixel vertical |
|
||||||
|
| | ...[0].currentResX | X | | X | X | | current pixel horizontal |
|
||||||
|
| | ...[0].currentResY | X | | X | X | | current pixel vertical |
|
||||||
|
| | ...[0].currentRefreshRate | X | | X | X | | current pixel vertical |
|
||||||
|
|
||||||
#### 7. Operating System
|
#### 7. Operating System
|
||||||
|
|
||||||
|
|||||||
@ -143,7 +143,17 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>monitor/display Array</td>
|
<td>monitor/display array</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>...[0].vendor</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>monitor/display vendor</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -153,7 +163,7 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>monitor/display Model</td>
|
<td>monitor/display model</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -183,7 +193,7 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>e.g. DisplayPort or HDMI</td>
|
<td>e.g. DisplayPort, HDMI</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -235,6 +245,36 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>pixel vertical</td>
|
<td>pixel vertical</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>...[0].currentResX</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>current pixel horizontal</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>...[0].currentResY</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>current pixel vertical</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>...[0].currentRefreshRate</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td></td>
|
||||||
|
<td>current pixel vertical</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
117
lib/graphics.js
117
lib/graphics.js
@ -30,14 +30,7 @@ const _sunos = (_platform === 'sunos');
|
|||||||
let _resolutionx = 0;
|
let _resolutionx = 0;
|
||||||
let _resolutiony = 0;
|
let _resolutiony = 0;
|
||||||
let _pixeldepth = 0;
|
let _pixeldepth = 0;
|
||||||
|
let _refreshrate = 0;
|
||||||
function toInt(value) {
|
|
||||||
let result = parseInt(value, 10);
|
|
||||||
if (isNaN(result)) {
|
|
||||||
result = 0;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function graphics(callback) {
|
function graphics(callback) {
|
||||||
|
|
||||||
@ -55,6 +48,7 @@ function graphics(callback) {
|
|||||||
vramDynamic: false
|
vramDynamic: false
|
||||||
};
|
};
|
||||||
let currentDisplay = {
|
let currentDisplay = {
|
||||||
|
vendor: '',
|
||||||
model: '',
|
model: '',
|
||||||
main: false,
|
main: false,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
@ -63,7 +57,10 @@ function graphics(callback) {
|
|||||||
sizey: -1,
|
sizey: -1,
|
||||||
pixeldepth: -1,
|
pixeldepth: -1,
|
||||||
resolutionx: -1,
|
resolutionx: -1,
|
||||||
resolutiony: -1
|
resolutiony: -1,
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
};
|
};
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
if ('' !== lines[i].trim()) {
|
if ('' !== lines[i].trim()) {
|
||||||
@ -86,6 +83,7 @@ function graphics(callback) {
|
|||||||
if (Object.keys(currentDisplay).length > 0) {// just changed to Displays
|
if (Object.keys(currentDisplay).length > 0) {// just changed to Displays
|
||||||
displays.push(currentDisplay);
|
displays.push(currentDisplay);
|
||||||
currentDisplay = {
|
currentDisplay = {
|
||||||
|
vendor: '',
|
||||||
model: '',
|
model: '',
|
||||||
main: false,
|
main: false,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
@ -94,7 +92,10 @@ function graphics(callback) {
|
|||||||
sizey: -1,
|
sizey: -1,
|
||||||
pixeldepth: -1,
|
pixeldepth: -1,
|
||||||
resolutionx: -1,
|
resolutionx: -1,
|
||||||
resolutiony: -1
|
resolutiony: -1,
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +116,7 @@ function graphics(callback) {
|
|||||||
}
|
}
|
||||||
if (3 === level) { // display controller level
|
if (3 === level) { // display controller level
|
||||||
if (parts.length > 1 && '' === parts[1]) {
|
if (parts.length > 1 && '' === parts[1]) {
|
||||||
|
currentDisplay.vendor = '';
|
||||||
currentDisplay.model = parts[0].trim();
|
currentDisplay.model = parts[0].trim();
|
||||||
currentDisplay.main = false;
|
currentDisplay.main = false;
|
||||||
currentDisplay.builtin = false;
|
currentDisplay.builtin = false;
|
||||||
@ -129,6 +131,8 @@ function graphics(callback) {
|
|||||||
let resolution = parts[1].split('x');
|
let resolution = parts[1].split('x');
|
||||||
currentDisplay.resolutionx = (resolution.length > 1 ? parseInt(resolution[0]) : 0);
|
currentDisplay.resolutionx = (resolution.length > 1 ? parseInt(resolution[0]) : 0);
|
||||||
currentDisplay.resolutiony = (resolution.length > 1 ? parseInt(resolution[1]) : 0);
|
currentDisplay.resolutiony = (resolution.length > 1 ? parseInt(resolution[1]) : 0);
|
||||||
|
currentDisplay.currentResX = currentDisplay.resolutionx;
|
||||||
|
currentDisplay.currentResY = currentDisplay.resolutiony;
|
||||||
}
|
}
|
||||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) currentDisplay.pixeldepth = parseInt(parts[1]); // in BIT
|
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) currentDisplay.pixeldepth = parseInt(parts[1]); // in BIT
|
||||||
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) currentDisplay.pixeldepth = parseInt(parts[1]); // in BIT
|
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) currentDisplay.pixeldepth = parseInt(parts[1]); // in BIT
|
||||||
@ -264,6 +268,7 @@ function graphics(callback) {
|
|||||||
// --> sizex
|
// --> sizex
|
||||||
// --> sizey
|
// --> sizey
|
||||||
let result = {
|
let result = {
|
||||||
|
vendor: '',
|
||||||
model: '',
|
model: '',
|
||||||
main: false,
|
main: false,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
@ -272,7 +277,10 @@ function graphics(callback) {
|
|||||||
sizey: -1,
|
sizey: -1,
|
||||||
pixeldepth: -1,
|
pixeldepth: -1,
|
||||||
resolutionx: -1,
|
resolutionx: -1,
|
||||||
resolutiony: -1
|
resolutiony: -1,
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
};
|
};
|
||||||
// find first "Detailed Timing Description"
|
// find first "Detailed Timing Description"
|
||||||
let start = 108;
|
let start = 108;
|
||||||
@ -299,9 +307,13 @@ function graphics(callback) {
|
|||||||
if (model_raw.indexOf('0a') !== -1) {
|
if (model_raw.indexOf('0a') !== -1) {
|
||||||
model_raw = model_raw.substr(0, model_raw.indexOf('0a'));
|
model_raw = model_raw.substr(0, model_raw.indexOf('0a'));
|
||||||
}
|
}
|
||||||
result.model = model_raw.match(/.{1,2}/g).map(function (v) {
|
try {
|
||||||
return String.fromCharCode(parseInt(v, 16));
|
result.model = model_raw.match(/.{1,2}/g).map(function (v) {
|
||||||
}).join('');
|
return String.fromCharCode(parseInt(v, 16));
|
||||||
|
}).join('');
|
||||||
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result.model = '';
|
result.model = '';
|
||||||
}
|
}
|
||||||
@ -311,6 +323,7 @@ function graphics(callback) {
|
|||||||
function parseLinesLinuxDisplays(lines, depth) {
|
function parseLinesLinuxDisplays(lines, depth) {
|
||||||
let displays = [];
|
let displays = [];
|
||||||
let currentDisplay = {
|
let currentDisplay = {
|
||||||
|
vendor: '',
|
||||||
model: '',
|
model: '',
|
||||||
main: false,
|
main: false,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
@ -319,9 +332,13 @@ function graphics(callback) {
|
|||||||
sizey: -1,
|
sizey: -1,
|
||||||
pixeldepth: -1,
|
pixeldepth: -1,
|
||||||
resolutionx: -1,
|
resolutionx: -1,
|
||||||
resolutiony: -1
|
resolutiony: -1,
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
};
|
};
|
||||||
let is_edid = false;
|
let is_edid = false;
|
||||||
|
let is_current = false;
|
||||||
let edid_raw = '';
|
let edid_raw = '';
|
||||||
let start = 0;
|
let start = 0;
|
||||||
for (let i = 1; i < lines.length; i++) { // start with second line
|
for (let i = 1; i < lines.length; i++) { // start with second line
|
||||||
@ -330,6 +347,7 @@ function graphics(callback) {
|
|||||||
if (currentDisplay.model || currentDisplay.main || currentDisplay.builtin || currentDisplay.connection || currentDisplay.sizex !== -1 || currentDisplay.pixeldepth !== -1 || currentDisplay.resolutionx !== -1) { // push last display to array
|
if (currentDisplay.model || currentDisplay.main || currentDisplay.builtin || currentDisplay.connection || currentDisplay.sizex !== -1 || currentDisplay.pixeldepth !== -1 || currentDisplay.resolutionx !== -1) { // push last display to array
|
||||||
displays.push(currentDisplay);
|
displays.push(currentDisplay);
|
||||||
currentDisplay = {
|
currentDisplay = {
|
||||||
|
vendor: '',
|
||||||
model: '',
|
model: '',
|
||||||
main: false,
|
main: false,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
@ -338,12 +356,15 @@ function graphics(callback) {
|
|||||||
sizey: -1,
|
sizey: -1,
|
||||||
pixeldepth: -1,
|
pixeldepth: -1,
|
||||||
resolutionx: -1,
|
resolutionx: -1,
|
||||||
resolutiony: -1
|
resolutiony: -1,
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let parts = lines[i].split(' ');
|
let parts = lines[i].split(' ');
|
||||||
currentDisplay.connection = parts[0];
|
currentDisplay.connection = parts[0];
|
||||||
currentDisplay.main = (parts[2] === 'primary');
|
currentDisplay.main = lines[i].toLowerCase().indexOf(' primary ') >= 0;
|
||||||
currentDisplay.builtin = (parts[0].toLowerCase().indexOf('edp') >= 0);
|
currentDisplay.builtin = (parts[0].toLowerCase().indexOf('edp') >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,6 +375,7 @@ function graphics(callback) {
|
|||||||
} else {
|
} else {
|
||||||
// parsen EDID
|
// parsen EDID
|
||||||
let edid_decoded = parseLinesLinuxEdid(edid_raw);
|
let edid_decoded = parseLinesLinuxEdid(edid_raw);
|
||||||
|
currentDisplay.vendor = edid_decoded.vendor;
|
||||||
currentDisplay.model = edid_decoded.model;
|
currentDisplay.model = edid_decoded.model;
|
||||||
currentDisplay.resolutionx = edid_decoded.resolutionx;
|
currentDisplay.resolutionx = edid_decoded.resolutionx;
|
||||||
currentDisplay.resolutiony = edid_decoded.resolutiony;
|
currentDisplay.resolutiony = edid_decoded.resolutiony;
|
||||||
@ -363,10 +385,26 @@ function graphics(callback) {
|
|||||||
is_edid = false;
|
is_edid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lines[i].toLowerCase().indexOf('edid:') !== -1) {
|
if (lines[i].toLowerCase().indexOf('edid:') >= 0) {
|
||||||
is_edid = true;
|
is_edid = true;
|
||||||
start = lines[i].search(/\S|$/);
|
start = lines[i].search(/\S|$/);
|
||||||
}
|
}
|
||||||
|
if (lines[i].toLowerCase().indexOf('*current') >= 0) {
|
||||||
|
const parts1 = lines[i].split('(');
|
||||||
|
if (parts1 && parts1.length > 1 && parts1[0].indexOf('x') >= 0) {
|
||||||
|
const resParts = parts1[0].trim().split('x');
|
||||||
|
currentDisplay.currentResolutionx = util.toInt(resParts[0]);
|
||||||
|
currentDisplay.currentResolutiony = util.toInt(resParts[1]);
|
||||||
|
}
|
||||||
|
is_current = true;
|
||||||
|
}
|
||||||
|
if (is_current && lines[i].toLowerCase().indexOf('clock') >= 0 && lines[i].toLowerCase().indexOf('hz') >= 0 && lines[i].toLowerCase().indexOf('v: height') >= 0) {
|
||||||
|
const parts1 = lines[i].split('clock');
|
||||||
|
if (parts1 && parts1.length > 1 && parts1[1].toLowerCase().indexOf('hz') >= 0) {
|
||||||
|
currentDisplay.currentRefreshRate = util.toInt(parts1[1]);
|
||||||
|
}
|
||||||
|
is_current = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +445,7 @@ function graphics(callback) {
|
|||||||
const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
|
const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
|
||||||
if (parts.length === 2) {
|
if (parts.length === 2) {
|
||||||
result.displays.push({
|
result.displays.push({
|
||||||
|
vendor: '',
|
||||||
model: util.getValue(lines, 'device_name', '='),
|
model: util.getValue(lines, 'device_name', '='),
|
||||||
main: true,
|
main: true,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
@ -415,7 +454,10 @@ function graphics(callback) {
|
|||||||
sizey: -1,
|
sizey: -1,
|
||||||
pixeldepth: -1,
|
pixeldepth: -1,
|
||||||
resolutionx: parseInt(parts[0], 10),
|
resolutionx: parseInt(parts[0], 10),
|
||||||
resolutiony: parseInt(parts[1], 10)
|
resolutiony: parseInt(parts[1], 10),
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,24 +515,27 @@ function graphics(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
||||||
try {
|
try {
|
||||||
util.wmic('path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate, VideoMemoryType /value').then((stdout, error) => {
|
util.wmic('path win32_VideoController get /value').then((stdout, error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let csections = stdout.split(/\n\s*\n/);
|
let csections = stdout.split(/\n\s*\n/);
|
||||||
result.controllers = parseLinesWindowsControllers(csections);
|
result.controllers = parseLinesWindowsControllers(csections);
|
||||||
util.wmic('path win32_desktopmonitor get Caption, MonitorManufacturer, MonitorType, ScreenWidth, ScreenHeight /value').then((stdout, error) => {
|
util.wmic('path win32_desktopmonitor get /value').then((stdout, error) => {
|
||||||
let dsections = stdout.split(/\n\s*\n/);
|
let dsections = stdout.split(/\n\s*\n/);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
result.displays = parseLinesWindowsDisplays(dsections);
|
result.displays = parseLinesWindowsDisplays(dsections);
|
||||||
if (result.controllers.length === 1 && result.displays.length === 1) {
|
if (result.controllers.length === 1 && result.displays.length === 1) {
|
||||||
if (_resolutionx && !result.displays[0].resolutionx) {
|
if (_resolutionx) {
|
||||||
result.displays[0].resolutionx = _resolutionx;
|
result.displays[0].currentResX = _resolutionx;
|
||||||
}
|
}
|
||||||
if (_resolutiony && !result.displays[0].resolutiony) {
|
if (_resolutiony) {
|
||||||
result.displays[0].resolutiony = _resolutiony;
|
result.displays[0].currentResY = _resolutiony;
|
||||||
}
|
}
|
||||||
if (_pixeldepth) {
|
if (_pixeldepth) {
|
||||||
result.displays[0].pixeldepth = _pixeldepth;
|
result.displays[0].pixeldepth = _pixeldepth;
|
||||||
}
|
}
|
||||||
|
if (_refreshrate && !result.displays[0].refreshrate) {
|
||||||
|
result.displays[0].currentRefreshRate = _refreshrate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@ -519,15 +564,16 @@ function graphics(callback) {
|
|||||||
|
|
||||||
let lines = sections[i].trim().split('\r\n');
|
let lines = sections[i].trim().split('\r\n');
|
||||||
controllers.push({
|
controllers.push({
|
||||||
model: util.getValue(lines, 'name', '='),
|
|
||||||
vendor: util.getValue(lines, 'AdapterCompatibility', '='),
|
vendor: util.getValue(lines, 'AdapterCompatibility', '='),
|
||||||
|
model: util.getValue(lines, 'name', '='),
|
||||||
bus: util.getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '',
|
bus: util.getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '',
|
||||||
vram: parseInt(util.getValue(lines, 'AdapterRAM', '='), 10) / 1024 / 1024,
|
vram: parseInt(util.getValue(lines, 'AdapterRAM', '='), 10) / 1024 / 1024,
|
||||||
vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2')
|
vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2')
|
||||||
});
|
});
|
||||||
_resolutionx = toInt(util.getValue(lines, 'CurrentHorizontalResolution', '='));
|
_resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '='));
|
||||||
_resolutiony = toInt(util.getValue(lines, 'CurrentVerticalResolution', '='));
|
_resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '='));
|
||||||
_pixeldepth = toInt(util.getValue(lines, 'CurrentBitsPerPixel', '='));
|
_refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '='));
|
||||||
|
_pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '='));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,14 +587,19 @@ function graphics(callback) {
|
|||||||
if (sections[i].trim() !== '') {
|
if (sections[i].trim() !== '') {
|
||||||
let lines = sections[i].trim().split('\r\n');
|
let lines = sections[i].trim().split('\r\n');
|
||||||
displays.push({
|
displays.push({
|
||||||
model: util.getValue(lines, 'MonitorManufacturer', '='),
|
vendor: util.getValue(lines, 'MonitorManufacturer', '='),
|
||||||
|
model: util.getValue(lines, 'Name', '='),
|
||||||
main: false,
|
main: false,
|
||||||
builtin: false,
|
builtin: false,
|
||||||
connection: '',
|
connection: '',
|
||||||
resolutionx: toInt(util.getValue(lines, 'ScreenWidth', '=')),
|
|
||||||
resolutiony: toInt(util.getValue(lines, 'ScreenHeight', '=')),
|
|
||||||
sizex: -1,
|
sizex: -1,
|
||||||
sizey: -1
|
sizey: -1,
|
||||||
|
pixeldepth: -1,
|
||||||
|
resolutionx: util.toInt(util.getValue(lines, 'ScreenWidth', '=')),
|
||||||
|
resolutiony: util.toInt(util.getValue(lines, 'ScreenHeight', '=')),
|
||||||
|
currentResX: -1,
|
||||||
|
currentResY: -1,
|
||||||
|
currentRefreshRate: -1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
lib/index.d.ts
vendored
4
lib/index.d.ts
vendored
@ -167,6 +167,7 @@ export namespace Systeminformation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface GraphicsDisplayData {
|
interface GraphicsDisplayData {
|
||||||
|
vendor: string;
|
||||||
model: string;
|
model: string;
|
||||||
main: boolean;
|
main: boolean;
|
||||||
builtin: boolean;
|
builtin: boolean;
|
||||||
@ -176,6 +177,9 @@ export namespace Systeminformation {
|
|||||||
pixeldepth: number;
|
pixeldepth: number;
|
||||||
resolutionx: number;
|
resolutionx: number;
|
||||||
resolutiony: number;
|
resolutiony: number;
|
||||||
|
currentResX: number;
|
||||||
|
currentResY: number;
|
||||||
|
currentRefreshRate: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Operating System
|
// 4. Operating System
|
||||||
|
|||||||
10
lib/util.js
10
lib/util.js
@ -38,6 +38,15 @@ const execOptsWin = {
|
|||||||
encoding: 'UTF-8'
|
encoding: 'UTF-8'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function toInt(value) {
|
||||||
|
let result = parseInt(value, 10);
|
||||||
|
if (isNaN(result)) {
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function isFunction(functionToCheck) {
|
function isFunction(functionToCheck) {
|
||||||
let getType = {};
|
let getType = {};
|
||||||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
||||||
@ -397,6 +406,7 @@ function countUniqueLines(lines, startingWith) {
|
|||||||
}
|
}
|
||||||
function noop() { }
|
function noop() { }
|
||||||
|
|
||||||
|
exports.toInt = toInt;
|
||||||
exports.execOptsWin = execOptsWin;
|
exports.execOptsWin = execOptsWin;
|
||||||
exports.getCodepage = getCodepage;
|
exports.getCodepage = getCodepage;
|
||||||
exports.execWin = execWin;
|
exports.execWin = execWin;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user