chassis() type, assetTag, sku improved parsing (macOS)

This commit is contained in:
Sebastian Hildebrandt 2024-03-14 05:02:18 +01:00
parent f1f2ccd927
commit 1744982db0
4 changed files with 47 additions and 7 deletions

View File

@ -83,6 +83,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- | | ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.22.1 | 2024-03-14 | `chassis()` type, assetTag, sku improved parsing (macOS) |
| 5.22.1 | 2024-03-12 | `wifiConnections()` patch for mac OS Sonome 14.4 (macOS) | | 5.22.1 | 2024-03-12 | `wifiConnections()` patch for mac OS Sonome 14.4 (macOS) |
| 5.22.0 | 2024-02-18 | `wifiConnections()` added signal quality attribute | | 5.22.0 | 2024-02-18 | `wifiConnections()` added signal quality attribute |
| 5.21.25 | 2024-02-17 | `wifiConnections()` fixed signal strength (windows) | | 5.21.25 | 2024-02-17 | `wifiConnections()` fixed signal strength (windows) |

View File

@ -57,6 +57,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">5.22.2</th>
<td>2024-03-14</td>
<td><span class="code">chassis()</span> type, assetTag, sku improved parsing (macOS)</td>
</tr>
<tr> <tr>
<th scope="row">5.22.1</th> <th scope="row">5.22.1</th>
<td>2024-03-12</td> <td>2024-03-12</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo"> <img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div> <div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div> <div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.22.1</span></div> <div class="version">New Version: <span id="version">5.22.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> <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>
<div class="down"> <div class="down">

View File

@ -215,12 +215,14 @@ function system(callback) {
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) { exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
if (!error) { if (!error) {
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n'); let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
const model = splitByNumber(util.getValue(lines, 'model', '=', true));
const version = util.getValue(lines, 'version', '=', true);
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true); result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
result.model = util.getValue(lines, 'model', '=', true, true); result.model = version ? util.getValue(lines, 'model', '=', true) : model[0];
result.version = util.getValue(lines, 'version', '=', true); result.version = version || model[1];
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true); result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase(); result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase();
result.sku = util.getValue(lines, 'board-id', '=', true); result.sku = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-sub-type', '=', true);
} }
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
@ -602,6 +604,33 @@ function baseboard(callback) {
exports.baseboard = baseboard; exports.baseboard = baseboard;
function macOsChassisType(model) {
model = model.toLowerCase();
if (model.startsWith('macbookair')) { return 'Notebook'; }
if (model.startsWith('macbookpro')) { return 'Laptop'; }
if (model.startsWith('macbook')) { return 'Notebook'; }
if (model.startsWith('macmini')) { return 'Desktop'; }
if (model.startsWith('imac')) { return 'Desktop'; }
if (model.startsWith('macstudio')) { return 'Desktop'; }
if (model.startsWith('macpro')) { return 'Tower'; }
return 'Other';
}
function splitByNumber(str) {
let numberStarted = false;
let num = '';
let cpart = '';
for (const c of str) {
if ((c >= '0' && c <= '9') || numberStarted) {
numberStarted = true;
num += c;
} else {
cpart += c;
}
}
return [cpart, num];
}
function chassis(callback) { function chassis(callback) {
const chassisTypes = ['Other', const chassisTypes = ['Other',
'Unknown', 'Unknown',
@ -680,11 +709,16 @@ function chassis(callback) {
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) { exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
if (!error) { if (!error) {
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n'); let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
const model = util.getValue(lines, 'model', '=', true);
const modelParts = splitByNumber(model);
const version = util.getValue(lines, 'version', '=', true);
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true); result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
result.model = util.getValue(lines, 'model', '=', true); result.model = version ? util.getValue(lines, 'model', '=', true) : modelParts[0];
result.version = util.getValue(lines, 'version', '=', true); result.type = macOsChassisType(result.model);
result.version = version || model;
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true); result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
result.assetTag = util.getValue(lines, 'board-id', '=', true); result.assetTag = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-type', '=', true);
result.sku = util.getValue(lines, 'target-sub-type', '=', true);
} }
if (callback) { callback(result); } if (callback) { callback(result); }