Skip to content

Commit

Permalink
battery() fixed parsing (linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Sep 20, 2023
1 parent f6a0bd3 commit 51a3744
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
5 changes: 5 additions & 0 deletions docs/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ <h3>Full version history</h3>
</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>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
3 changes: 3 additions & 0 deletions lib/battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 51a3744

Please sign in to comment.