battery() timeremaining optimization (linux)

This commit is contained in:
Sebastian Hildebrandt 2018-11-21 22:59:40 +01:00
parent fc63865f33
commit 8dad45b5fa
3 changed files with 5 additions and 0 deletions

View File

@ -100,6 +100,7 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.49.4 | 2018-11-21 | `battery()` timeremaining optimization (linux) thanks to Jorai Rijsdijk |
| 3.49.3 | 2018-11-20 | `memLayout()` optimized parsing (win) |
| 3.49.2 | 2018-11-19 | code cleanup |
| 3.49.1 | 2018-11-19 | `cpu().brand` removed extra spaces, tabs |

View File

@ -586,6 +586,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
- Jimi M [ItsJimi](https://github.com/ItsJimi)
- Git² [GitSquared](https://github.com/GitSquared)
- weiyin [weiyin](https://github.com/weiyin)
- Jorai Rijsdijk [Erackron](https://github.com/Erackron)
OSX Temperature: credits here are going to:

View File

@ -70,6 +70,7 @@ module.exports = function (callback) {
const percent = util.getValue(lines, 'POWER_SUPPLY_CAPACITY', '=');
const energy = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10);
const power = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_POWER_NOW', '='), 10);
const current = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CURRENT_NOW', '='), 10);
result.percent = parseInt('0' + percent, 10);
if (result.maxcapacity && result.currentcapacity) {
@ -83,6 +84,8 @@ module.exports = function (callback) {
}
if (energy && power) {
result.timeremaining = Math.floor(energy / power * 60);
} else if (current && result.currentcapacity) {
result.timeremaining = Math.floor(result.currentcapacity / current * 60);
}
result.type = util.getValue(lines, 'POWER_SUPPLY_TECHNOLOGY', '=');
result.model = util.getValue(lines, 'POWER_SUPPLY_MODEL_NAME', '=');