Skip to content

Commit 51a3744

Browse files
battery() fixed parsing (linux)
1 parent f6a0bd3 commit 51a3744

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
8383

8484
| Version | Date | Comment |
8585
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
86+
| 5.21.8 | 2023-09-20 | `battery()` fixed parsing (linux) |
8687
| 5.21.7 | 2023-09-19 | `wifiConnections()` `wifiNetworks()` fixed security issue (linux) |
8788
| 5.21.6 | 2023-09-18 | `baseboard()` improved parsing (windows) |
8889
| 5.21.5 | 2023-09-15 | `chassis()`, `baseboard()` improved parsing (windows) |

docs/history.html

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ <h3>Full version history</h3>
5757
</tr>
5858
</thead>
5959
<tbody>
60+
<tr>
61+
<th scope="row">5.21.8</th>
62+
<td>2023-09-20</td>
63+
<td><span class="code">battery()</span> fixed parsing (linux)</td>
64+
</tr>
6065
<tr>
6166
<th scope="row">5.21.7</th>
6267
<td>2023-09-19</td>

docs/index.html

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

lib/battery.js

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ module.exports = function (callback) {
127127
const energy = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10);
128128
const power = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_POWER_NOW', '='), 10);
129129
const current = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CURRENT_NOW', '='), 10);
130+
const charge = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10);
130131

131132
result.percent = parseInt('0' + percent, 10);
132133
if (result.maxCapacity && result.currentCapacity) {
@@ -140,6 +141,8 @@ module.exports = function (callback) {
140141
}
141142
if (energy && power) {
142143
result.timeRemaining = Math.floor(energy / power * 60);
144+
} else if (current && charge) {
145+
result.timeRemaining = Math.floor(charge / current * 60);
143146
} else if (current && result.currentCapacity) {
144147
result.timeRemaining = Math.floor(result.currentCapacity / current * 60);
145148
}

0 commit comments

Comments
 (0)