cpuTemperature() fix (linux)
This commit is contained in:
parent
8c6aba748e
commit
ca704aaf46
23
lib/audio.js
23
lib/audio.js
@ -28,8 +28,10 @@ const _netbsd = (_platform === 'netbsd');
|
||||
const _sunos = (_platform === 'sunos');
|
||||
|
||||
function parseAudioType(str, input, output) {
|
||||
str = str.toLowerCase();
|
||||
let result = '';
|
||||
|
||||
if (str.indexOf('display audio') >= 0) { result = 'Speaker'; }
|
||||
if (str.indexOf('speak') >= 0) { result = 'Speaker'; }
|
||||
if (str.indexOf('laut') >= 0) { result = 'Speaker'; }
|
||||
if (str.indexOf('loud') >= 0) { result = 'Speaker'; }
|
||||
@ -55,15 +57,15 @@ function getLinuxAudioPci() {
|
||||
let result = [];
|
||||
try {
|
||||
const parts = execSync(cmd).toString().split('\n\n');
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const lines = parts[i].split('\n');
|
||||
parts.forEach(element => {
|
||||
const lines = element.split('\n');
|
||||
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
|
||||
const audio = {};
|
||||
audio.slotId = lines[0].split(' ')[0];
|
||||
audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true);
|
||||
result.push(audio);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} catch (e) {
|
||||
return result;
|
||||
@ -154,13 +156,13 @@ function audio(callback) {
|
||||
if (!error) {
|
||||
const audioPCI = getLinuxAudioPci();
|
||||
const parts = stdout.toString().split('\n\n');
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const lines = parts[i].split('\n');
|
||||
parts.forEach(element => {
|
||||
const lines = element.split('\n');
|
||||
if (util.getValue(lines, 'class', ':', true).toLowerCase().indexOf('audio') >= 0) {
|
||||
const audio = parseLinuxAudioPciMM(lines, audioPCI);
|
||||
result.push(audio);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
@ -194,11 +196,12 @@ function audio(callback) {
|
||||
util.powerShell('Get-CimInstance Win32_SoundDevice | select DeviceID,StatusInfo,Name,Manufacturer | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (util.getValue(parts[i].split('\n'), 'name', ':')) {
|
||||
result.push(parseWindowsAudio(parts[i].split('\n')));
|
||||
parts.forEach(element => {
|
||||
const lines = element.split('\n');
|
||||
if (util.getValue(lines, 'name', ':')) {
|
||||
result.push(parseWindowsAudio(lines));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
|
||||
@ -1044,13 +1044,15 @@ function cpuTemperature(callback) {
|
||||
const value = parts.length > 1 && parts[1] ? parts[1] : '0';
|
||||
if (value && (label === undefined || (label && label.toLowerCase().startsWith('core')))) {
|
||||
result.cores.push(Math.round(parseInt(value, 10) / 100) / 10);
|
||||
} else if (value && label && result.main === null) {
|
||||
} else if (value && label && result.main === null && (label.toLowerCase().indexOf('package') >= 0 || label.toLowerCase().startsWith('physical') >= 0)) {
|
||||
result.main = Math.round(parseInt(value, 10) / 100) / 10;
|
||||
}
|
||||
});
|
||||
|
||||
if (result.cores.length > 0) {
|
||||
result.main = Math.round(result.cores.reduce((a, b) => a + b, 0) / result.cores.length);
|
||||
if (result.main === null) {
|
||||
result.main = Math.round(result.cores.reduce((a, b) => a + b, 0) / result.cores.length);
|
||||
}
|
||||
let maxtmp = Math.max.apply(Math, result.cores);
|
||||
result.max = (maxtmp > result.main) ? maxtmp : result.main;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user