battery() fixed parsing (linux)
This commit is contained in:
@@ -127,6 +127,7 @@ module.exports = function (callback) {
|
||||
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);
|
||||
const charge = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10);
|
||||
|
||||
result.percent = parseInt('0' + percent, 10);
|
||||
if (result.maxCapacity && result.currentCapacity) {
|
||||
@@ -140,6 +141,8 @@ module.exports = function (callback) {
|
||||
}
|
||||
if (energy && power) {
|
||||
result.timeRemaining = Math.floor(energy / power * 60);
|
||||
} else if (current && charge) {
|
||||
result.timeRemaining = Math.floor(charge / current * 60);
|
||||
} else if (current && result.currentCapacity) {
|
||||
result.timeRemaining = Math.floor(result.currentCapacity / current * 60);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user