Skip to content

Commit

Permalink
battery() improved serial and model parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Jan 5, 2025
1 parent ae3128c commit 85add8e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.

| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.25.1 | 2025-01-05 | `cpuCurrentSpeed()` denno speed workarround |
| 5.25.2 | 2025-01-05 | `battery()` improved serial and model parsing |
| 5.25.1 | 2025-01-05 | `cpuCurrentSpeed()` Deno CPU speed workarround (linux) |
| 5.25.0 | 2025-01-05 | `versions()` added homebrew |
| 5.24.9 | 2025-01-04 | `checkWebsite()` reestablished certificate validation |
| 5.24.9 | 2025-01-04 | `checkWebsite()` reestablished certificate validation |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ si.cpu()

(last 7 major and minor version releases)

- Version 5.24.0: `versions()` added homebrew
- Version 5.25.0: `versions()` added homebrew
- Version 5.24.0: `versions()` added bun and deno
- Version 5.23.0: `usb()` added serial number (linux)
- Version 5.22.0: `wifiConnections()` added signal quality
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.25.2</th>
<td>2024-01-05</td>
<td><span class="code">battery()</span> improved model and serial parsing (macOS)</td>
</tr>
<tr>
<th scope="row">5.25.1</th>
<td>2024-01-05</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>
3<div class="version">New Version: <span id="version">5.25.1</span></div>
3<div class="version">New Version: <span id="version">5.25.2</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
5 changes: 3 additions & 2 deletions lib/battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ module.exports = function (callback) {
}

if (_darwin) {
exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|BatterySerialNumber|TimeRemaining|Voltage"; pmset -g batt | grep %', function (error, stdout) {
exec('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage"; pmset -g batt | grep %', function (error, stdout) {
if (stdout) {
let lines = stdout.toString().replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
result.cycleCount = parseInt('0' + util.getValue(lines, 'cyclecount', '='), 10);
Expand All @@ -191,7 +191,8 @@ module.exports = function (callback) {
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawcurrentcapacity', '='), 10) * (result.voltage || 1));
result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
result.manufacturer = 'Apple';
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
result.serial = util.getValue(lines, 'BatterySerialNumber', '=') || util.getValue(lines, 'Serial', '=');
result.model = util.getValue(lines, 'DeviceName', '=');
let percent = null;
const line = util.getValue(lines, 'internal', 'Battery');
let parts = line.split(';');
Expand Down
2 changes: 1 addition & 1 deletion lib/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ function getCpuCurrentSpeedSync() {
if (speeds[i] < minFreq) { minFreq = speeds[i]; }
cores.push(parseFloat(speeds[i].toFixed(2)));
}
avgFreq = avgFreq / cpus.length;
avgFreq = avgFreq / speeds.length;
return {
min: parseFloat(minFreq.toFixed(2)),
max: parseFloat(maxFreq.toFixed(2)),
Expand Down
6 changes: 3 additions & 3 deletions lib/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function system(callback) {
if (_linux || _freebsd || _openbsd || _netbsd) {
exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', function (error, stdout) {
let lines = stdout.toString().split('\n');
result.manufacturer = util.getValue(lines, 'manufacturer');
result.model = util.getValue(lines, 'product name');
result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer'));
result.model = cleanDefaults(util.getValue(lines, 'product name'));
result.version = cleanDefaults(util.getValue(lines, 'version'));
result.serial = cleanDefaults(util.getValue(lines, 'serial number'));
result.uuid = cleanDefaults((util.getValue(lines, 'uuid').toLowerCase()));
result.uuid = cleanDefaults((util.getValue(lines, 'uuid'))).toLowerCase();
result.sku = cleanDefaults(util.getValue(lines, 'sku number'));
// Non-Root values
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
Expand Down

0 comments on commit 85add8e

Please sign in to comment.