optimized OSX battery
This commit is contained in:
parent
6eb98db668
commit
369b3c0f3f
@ -99,6 +99,7 @@ Other changes
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 3.33.15 | 2018-01-21 | optimized OSX battery |
|
||||||
| 3.33.14 | 2018-01-17 | bugfix `diskLayout()` (Windows) |
|
| 3.33.14 | 2018-01-17 | bugfix `diskLayout()` (Windows) |
|
||||||
| 3.33.13 | 2018-01-12 | bugfix `memLayout()` (Windows) |
|
| 3.33.13 | 2018-01-12 | bugfix `memLayout()` (Windows) |
|
||||||
| 3.33.12 | 2017-12-25 | fixed typos |
|
| 3.33.12 | 2017-12-25 | fixed typos |
|
||||||
|
|||||||
@ -80,7 +80,7 @@ module.exports = function (callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec("ioreg -n AppleSmartBattery -r | grep '\"CycleCount\"';ioreg -n AppleSmartBattery -r | grep '\"IsCharging\"';ioreg -n AppleSmartBattery -r | grep '\"MaxCapacity\"';ioreg -n AppleSmartBattery -r | grep '\"CurrentCapacity\"'", function (error, stdout) {
|
exec("ioreg -n AppleSmartBattery -r | grep '\"CycleCount\"';ioreg -n AppleSmartBattery -r | grep '\"IsCharging\"';ioreg -n AppleSmartBattery -r | grep '\"MaxCapacity\"';ioreg -n AppleSmartBattery -r | grep '\"CurrentCapacity\"';pmset -g batt | grep %", function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').split('\n');
|
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').split('\n');
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
@ -88,7 +88,15 @@ module.exports = function (callback) {
|
|||||||
if (line.toLowerCase().indexOf('cyclecount') !== -1) result.cyclecount = parseFloat(line.split('=')[1].trim());
|
if (line.toLowerCase().indexOf('cyclecount') !== -1) result.cyclecount = parseFloat(line.split('=')[1].trim());
|
||||||
if (line.toLowerCase().indexOf('ischarging') !== -1) result.ischarging = (line.split('=')[1].trim().toLowerCase() === 'yes');
|
if (line.toLowerCase().indexOf('ischarging') !== -1) result.ischarging = (line.split('=')[1].trim().toLowerCase() === 'yes');
|
||||||
if (line.toLowerCase().indexOf('maxcapacity') !== -1) result.maxcapacity = parseFloat(line.split('=')[1].trim());
|
if (line.toLowerCase().indexOf('maxcapacity') !== -1) result.maxcapacity = parseFloat(line.split('=')[1].trim());
|
||||||
if (line.toLowerCase().indexOf('currentcapacity') !== -1) result.currentcapacity = parseFloat(line.split('=')[1].trim());
|
if (line.toLowerCase().indexOf('internalbattery') !== -1) {
|
||||||
|
let parts = line.split(';');
|
||||||
|
if (parts && parts[0]) {
|
||||||
|
let parts2 = parts[0].split('\t');
|
||||||
|
if (parts2 && parts2[1]) {
|
||||||
|
result.percent = parseFloat(parts2[1].trim().replace('%', ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user