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