graphics() raspian detection
This commit is contained in:
parent
5a7d5992b6
commit
fa7e7c5d12
@ -265,8 +265,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
||||
| | hostname | X | X | X | X | X | same as os.hostname() |
|
||||
| | codepage | X | X | X | X | | OS build version |
|
||||
| | logofile | X | X | X | X | X | e.g. 'apple', 'debian', 'fedora', ... |
|
||||
| | serial | | X | X | X | | OS/Host serial number |
|
||||
| | build | | | X | X | | OS build version |
|
||||
| | serial | X | X | X | X | | OS/Host serial number |
|
||||
| | build | X | | X | X | | OS build version |
|
||||
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
|
||||
| | os | X | X | X | X | | os specific UUID |
|
||||
| si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) |
|
||||
|
||||
@ -161,7 +161,7 @@
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>serial</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
@ -171,7 +171,7 @@
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>build</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
|
||||
@ -396,32 +396,65 @@ function graphics(callback) {
|
||||
});
|
||||
}
|
||||
if (_linux) {
|
||||
let cmd = 'lspci -vvv 2>/dev/null';
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.controllers = parseLinesLinuxControllers(lines);
|
||||
}
|
||||
let cmd = 'xdpyinfo 2>/dev/null | grep \'depth of root window\' | awk \'{ print $5 }\'';
|
||||
// Raspberry: https://elinux.org/RPI_vcgencmd_usage
|
||||
if (util.isRaspberry() && util.isRaspbian()) {
|
||||
let cmd = 'fbset -s | grep \'mode "\'; vcgencmd get_mem gpu; tvservice -s; tvservice -n;';
|
||||
exec(cmd, function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
if (lines.length > 3 && lines[0].indexOf('mode "' >= -1)) {
|
||||
const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
|
||||
if (parts.length === 2) {
|
||||
push({
|
||||
model: getValue(lines, 'device_name', '='),
|
||||
main: true,
|
||||
builtin: false,
|
||||
connection: 'HDMI',
|
||||
sizex: -1,
|
||||
sizey: -1,
|
||||
pixeldepth: -1,
|
||||
resolutionx: parseInt(parts[0], 10),
|
||||
resolutiony: parseInt(parts[1], 10)
|
||||
})
|
||||
}
|
||||
}
|
||||
if (lines.length > 1 && lines[1].indexOf('gpu=' >= -1) {
|
||||
push({
|
||||
vendor: 'Broadcom',
|
||||
model: 'VideoCore IV',
|
||||
bus: '',
|
||||
vram: lines[1].replace('gpu=', ''),
|
||||
vramDynamic: true
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let cmd = 'lspci -vvv 2>/dev/null';
|
||||
exec(cmd, function (error, stdout) {
|
||||
let depth = 0;
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
depth = parseInt(lines[0]) || 0;
|
||||
result.controllers = parseLinesLinuxControllers(lines);
|
||||
}
|
||||
let cmd = 'xrandr --verbose 2>/dev/null';
|
||||
let cmd = 'xdpyinfo 2>/dev/null | grep \'depth of root window\' | awk \'{ print $5 }\'';
|
||||
exec(cmd, function (error, stdout) {
|
||||
let depth = 0;
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.displays = parseLinesLinuxDisplays(lines, depth);
|
||||
depth = parseInt(lines[0]) || 0;
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
let cmd = 'xrandr --verbose 2>/dev/null';
|
||||
exec(cmd, function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.displays = parseLinesLinuxDisplays(lines, depth);
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if (_freebsd || _openbsd) {
|
||||
if (callback) { callback(result); }
|
||||
|
||||
31
lib/util.js
31
lib/util.js
@ -275,6 +275,35 @@ function getCodepage() {
|
||||
}
|
||||
}
|
||||
|
||||
function isRaspberry() {
|
||||
const PI_MODEL_NO = [
|
||||
'BCM2708',
|
||||
'BCM2709',
|
||||
'BCM2710',
|
||||
'BCM2835',
|
||||
'BCM2837B0'
|
||||
];
|
||||
let cpuinfo = [];
|
||||
try {
|
||||
cpuinfo = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).split('\n');
|
||||
} catch (e) {
|
||||
return false;
|
||||
};
|
||||
const hardware = getValue(cpuinfo, 'hardware');
|
||||
return (PI_MODEL_NO.indexOf(hardware) >= -1)
|
||||
}
|
||||
|
||||
function isRaspbian() {
|
||||
let osrelease = [];
|
||||
try {
|
||||
osrelease = fs.readFileSync('/etc/os-release', { encoding: 'utf8' }).split('\n');
|
||||
} catch (e) {
|
||||
return false;
|
||||
};
|
||||
const id = getValue(cpuinfo, 'id');
|
||||
return (id.indexOf('raspbian') >= -1)
|
||||
}
|
||||
|
||||
function execWin(cmd, opts, callback) {
|
||||
if (!callback) {
|
||||
callback = opts;
|
||||
@ -325,3 +354,5 @@ exports.powerShell = powerShell;
|
||||
exports.nanoSeconds = nanoSeconds;
|
||||
exports.countUniqueLines = countUniqueLines;
|
||||
exports.noop = noop;
|
||||
exports.isRaspberry = isRaspberry;
|
||||
exports.isRaspbian = isRaspbian;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user