battery() improved serial and model parsing
This commit is contained in:
+3
-2
@@ -181,7 +181,7 @@ module.exports = function (callback) {
|
||||
}
|
||||
|
||||
if (_darwin) {
|
||||
exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|BatterySerialNumber|TimeRemaining|Voltage"; pmset -g batt | grep %', function (error, stdout) {
|
||||
exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage"; pmset -g batt | grep %', function (error, stdout) {
|
||||
if (stdout) {
|
||||
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
|
||||
result.cycleCount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
|
||||
@@ -191,7 +191,8 @@ module.exports = function (callback) {
|
||||
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawcurrentcapacity', '='), 10) * (result.voltage || 1));
|
||||
result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
|
||||
result.manufacturer = 'Apple';
|
||||
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
||||
result.serial = util.getValue(lines, 'BatterySerialNumber', '=') || util.getValue(lines, 'Serial', '=');
|
||||
result.model = util.getValue(lines, 'DeviceName', '=');
|
||||
let percent = null;
|
||||
const line = util.getValue(lines, 'internal', 'Battery');
|
||||
let parts = line.split(';');
|
||||
|
||||
+1
-1
@@ -1019,7 +1019,7 @@ function getCpuCurrentSpeedSync() {
|
||||
if (speeds[i] < minFreq) { minFreq = speeds[i]; }
|
||||
cores.push(parseFloat(speeds[i].toFixed(2)));
|
||||
}
|
||||
avgFreq = avgFreq / cpus.length;
|
||||
avgFreq = avgFreq / speeds.length;
|
||||
return {
|
||||
min: parseFloat(minFreq.toFixed(2)),
|
||||
max: parseFloat(maxFreq.toFixed(2)),
|
||||
|
||||
+3
-3
@@ -48,11 +48,11 @@ function system(callback) {
|
||||
if (_linux || _freebsd || _openbsd || _netbsd) {
|
||||
exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer');
|
||||
result.model = util.getValue(lines, 'product name');
|
||||
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer'));
|
||||
result.model = cleanDefaults(util.getValue(lines, 'product name'));
|
||||
result.version = cleanDefaults(util.getValue(lines, 'version'));
|
||||
result.serial = cleanDefaults(util.getValue(lines, 'serial number'));
|
||||
result.uuid = cleanDefaults((util.getValue(lines, 'uuid').toLowerCase()));
|
||||
result.uuid = cleanDefaults((util.getValue(lines, 'uuid'))).toLowerCase();
|
||||
result.sku = cleanDefaults(util.getValue(lines, 'sku number'));
|
||||
// Non-Root values
|
||||
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
|
||||
|
||||
Reference in New Issue
Block a user