battery() fixed parsing (linux)

This commit is contained in:
Sebastian Hildebrandt 2023-09-20 06:07:17 +02:00
parent f6a0bd3fb2
commit 51a3744217
4 changed files with 10 additions and 1 deletions

View File

@ -83,6 +83,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.21.8 | 2023-09-20 | `battery()` fixed parsing (linux) |
| 5.21.7 | 2023-09-19 | `wifiConnections()` `wifiNetworks()` fixed security issue (linux) |
| 5.21.6 | 2023-09-18 | `baseboard()` improved parsing (windows) |
| 5.21.5 | 2023-09-15 | `chassis()`, `baseboard()` improved parsing (windows) |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.21.8</th>
<td>2023-09-20</td>
<td><span class="code">battery()</span> fixed parsing (linux)</td>
</tr>
<tr>
<th scope="row">5.21.7</th>
<td>2023-09-19</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.21.7</span></div>
<div class="version">New Version: <span id="version">5.21.8</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">

View File

@ -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);
}