battery() improved serial and model parsing

This commit is contained in:
Sebastian Hildebrandt 2025-01-05 15:12:52 +01:00
parent ae3128cc51
commit 85add8ec09
7 changed files with 16 additions and 9 deletions

View File

@ -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 |

View File

@ -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

View File

@ -57,6 +57,11 @@
</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>

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>
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">

View File

@ -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);
@ -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(';');

View File

@ -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)),

View File

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