battery() timeremaining optimization (linux)
This commit is contained in:
@@ -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', '=');
|
||||
|
||||
Reference in New Issue
Block a user