systeminformation 6.0.0-beta.1 → 6.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -7
- package/dist/bsd/network-stats.js +2 -2
- package/dist/common/darwin.d.ts +2 -0
- package/dist/common/darwin.js +17 -1
- package/dist/common/defaults.d.ts +2 -1
- package/dist/common/defaults.js +21 -5
- package/dist/common/exec.js +1 -1
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +10 -0
- package/dist/common/filesys.js +41 -10
- package/dist/common/host.js +55 -3
- package/dist/common/mappings.js +2 -1
- package/dist/common/network.js +4 -4
- package/dist/common/nvidia.d.ts +1 -1
- package/dist/common/nvidia.js +4 -5
- package/dist/common/parse.d.ts +4 -6
- package/dist/common/parse.js +24 -69
- package/dist/common/security.d.ts +1 -0
- package/dist/common/security.js +3 -1
- package/dist/common/types.d.ts +33 -5
- package/dist/cpu-current-load.js +28 -6
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/battery.d.ts +1 -1
- package/dist/darwin/battery.js +15 -5
- package/dist/darwin/camera.js +3 -3
- package/dist/darwin/disk-layout.js +16 -12
- package/dist/darwin/disks-io.js +3 -3
- package/dist/darwin/displays.js +34 -1
- package/dist/darwin/fans.d.ts +2 -0
- package/dist/darwin/fans.js +28 -0
- package/dist/darwin/gpu.js +1 -1
- package/dist/darwin/index.d.ts +2 -0
- package/dist/darwin/index.js +6 -2
- package/dist/darwin/keyboard.js +4 -4
- package/dist/darwin/mouse.js +4 -4
- package/dist/darwin/network-interfaces.js +5 -10
- package/dist/darwin/network-stats.js +5 -5
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- package/dist/fans.d.ts +1 -0
- package/dist/fans.js +17 -0
- package/dist/get-data.d.ts +4 -0
- package/dist/get-data.js +6 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -2
- package/dist/linux/audio.js +59 -0
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- package/dist/linux/camera.js +2 -1
- package/dist/linux/chassis.js +4 -10
- package/dist/linux/cpu-temperature.js +34 -19
- package/dist/linux/cpu.js +3 -1
- package/dist/linux/disk-layout.js +7 -10
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.js +40 -2
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.js +160 -34
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.js +15 -15
- package/dist/linux/index.d.ts +2 -0
- package/dist/linux/index.js +6 -2
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +36 -39
- package/dist/linux/network-stats.js +8 -36
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +19 -4
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-load.js +9 -12
- package/dist/linux/processes.js +89 -80
- package/dist/linux/serial-ports.d.ts +2 -0
- package/dist/linux/serial-ports.js +102 -0
- package/dist/linux/services.js +179 -47
- package/dist/linux/system.js +1 -7
- package/dist/linux/uuid.js +4 -10
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/versions.js +32 -77
- package/dist/windows/disk-layout.js +3 -0
- package/dist/windows/disks-io.js +3 -3
- package/dist/windows/displays.js +43 -12
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/index.d.ts +2 -0
- package/dist/windows/index.js +6 -2
- package/dist/windows/network-interfaces.js +20 -29
- package/dist/windows/network-stats.js +4 -2
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.js +17 -11
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +3 -0
- package/package.json +1 -1
package/dist/linux/bios.js
CHANGED
|
@@ -5,19 +5,14 @@ const common_1 = require("../common");
|
|
|
5
5
|
const defaults_1 = require("../common/defaults");
|
|
6
6
|
const datetime_1 = require("../common/datetime");
|
|
7
7
|
const exec_1 = require("../common/exec");
|
|
8
|
+
const files_1 = require("../common/files");
|
|
8
9
|
const const_1 = require("../common/const");
|
|
9
10
|
const bios = async () => {
|
|
10
11
|
await (0, common_1.nextTick)();
|
|
11
12
|
const result = (0, common_1.cloneObj)(defaults_1.initBios);
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
cmd = 'export LC_ALL=C; dmidecode -t bios 2>/dev/null; unset LC_ALL';
|
|
18
|
-
}
|
|
19
|
-
const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
|
|
20
|
-
let lines = stdout.toString().split('\n');
|
|
13
|
+
let lines = process.arch === 'arm'
|
|
14
|
+
? (await (0, files_1.readFileLines)('/proc/cpuinfo')).filter((line) => line.indexOf('Serial') >= 0)
|
|
15
|
+
: (await (0, exec_1.execSave)('export LC_ALL=C; dmidecode -t bios 2>/dev/null; unset LC_ALL', const_1.execOptsLinux)).stdout.split('\n');
|
|
21
16
|
result.vendor = (0, common_1.getValue)(lines, 'Vendor');
|
|
22
17
|
result.version = (0, common_1.getValue)(lines, 'Version');
|
|
23
18
|
let datetime = (0, common_1.getValue)(lines, 'Release Date');
|
|
@@ -28,7 +23,7 @@ const bios = async () => {
|
|
|
28
23
|
if (language) {
|
|
29
24
|
result.language = language;
|
|
30
25
|
}
|
|
31
|
-
if (lines.
|
|
26
|
+
if (lines.some((line) => line.indexOf('Characteristics:') >= 0)) {
|
|
32
27
|
const features = [];
|
|
33
28
|
lines.forEach((line) => {
|
|
34
29
|
if (line.indexOf(' is supported') >= 0) {
|
|
@@ -38,12 +33,8 @@ const bios = async () => {
|
|
|
38
33
|
});
|
|
39
34
|
result.features = features;
|
|
40
35
|
}
|
|
41
|
-
cmd = `echo -n "bios_date: "; cat /sys/devices/virtual/dmi/id/bios_date 2>/dev/null; echo;
|
|
42
|
-
echo -n "bios_vendor: "; cat /sys/devices/virtual/dmi/id/bios_vendor 2>/dev/null; echo;
|
|
43
|
-
echo -n "bios_version: "; cat /sys/devices/virtual/dmi/id/bios_version 2>/dev/null; echo;`;
|
|
44
36
|
try {
|
|
45
|
-
|
|
46
|
-
lines = stdout.split('\n');
|
|
37
|
+
lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['bios_date', 'bios_vendor', 'bios_version']);
|
|
47
38
|
result.vendor = !result.vendor ? (0, common_1.getValue)(lines, 'bios_vendor') : result.vendor;
|
|
48
39
|
result.version = !result.version ? (0, common_1.getValue)(lines, 'bios_version') : result.version;
|
|
49
40
|
datetime = (0, common_1.getValue)(lines, 'bios_date');
|
package/dist/linux/camera.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.camera = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
|
+
const security_1 = require("../common/security");
|
|
6
7
|
const V4L_PATH = '/sys/class/video4linux';
|
|
7
8
|
const readAttr = async (path) => {
|
|
8
9
|
try {
|
|
@@ -17,7 +18,7 @@ const camera = async () => {
|
|
|
17
18
|
const result = [];
|
|
18
19
|
const seen = new Set();
|
|
19
20
|
try {
|
|
20
|
-
const nodes = (await (0, promises_1.readdir)(V4L_PATH)).filter((node) => node.startsWith('video')).sort();
|
|
21
|
+
const nodes = (await (0, promises_1.readdir)(V4L_PATH)).filter((node) => node.startsWith('video') && (0, security_1.isSafePathSegment)(node)).sort();
|
|
21
22
|
for (const node of nodes) {
|
|
22
23
|
const base = `${V4L_PATH}/${node}`;
|
|
23
24
|
const name = await readAttr(`${base}/name`);
|
package/dist/linux/chassis.js
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.chassis = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
|
-
const
|
|
5
|
+
const files_1 = require("../common/files");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
7
|
const mappings_1 = require("../common/mappings");
|
|
8
8
|
const parse_1 = require("../common/parse");
|
|
9
|
-
const parseChassis = (
|
|
10
|
-
const lines = stdout.toString().split('\n');
|
|
9
|
+
const parseChassis = (lines, defaults) => {
|
|
11
10
|
const manufacturer = (0, parse_1.cleanDefaults)((0, common_1.getValue)(lines, 'chassis_vendor'));
|
|
12
11
|
const ctype = parseInt((0, common_1.getValue)(lines, 'chassis_type').replace(/\D/g, ''));
|
|
13
12
|
const chassisType = ctype && !isNaN(ctype) && ctype <= mappings_1.chassisTypes.length ? mappings_1.chassisTypes[ctype - 1] : '';
|
|
@@ -26,14 +25,9 @@ const parseChassis = (stdout, defaults) => {
|
|
|
26
25
|
const chassis = async () => {
|
|
27
26
|
await (0, common_1.nextTick)();
|
|
28
27
|
const defaults = (0, common_1.cloneObj)(defaults_1.initChassis);
|
|
29
|
-
const cmd = `echo -n "chassis_asset_tag: "; cat /sys/devices/virtual/dmi/id/chassis_asset_tag 2>/dev/null; echo;
|
|
30
|
-
echo -n "chassis_serial: "; cat /sys/devices/virtual/dmi/id/chassis_serial 2>/dev/null; echo;
|
|
31
|
-
echo -n "chassis_type: "; cat /sys/devices/virtual/dmi/id/chassis_type 2>/dev/null; echo;
|
|
32
|
-
echo -n "chassis_vendor: "; cat /sys/devices/virtual/dmi/id/chassis_vendor 2>/dev/null; echo;
|
|
33
|
-
echo -n "chassis_version: "; cat /sys/devices/virtual/dmi/id/chassis_version 2>/dev/null; echo;`;
|
|
34
28
|
try {
|
|
35
|
-
const
|
|
36
|
-
return parseChassis(
|
|
29
|
+
const lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['chassis_asset_tag', 'chassis_serial', 'chassis_type', 'chassis_vendor', 'chassis_version']);
|
|
30
|
+
return parseChassis(lines, defaults);
|
|
37
31
|
}
|
|
38
32
|
catch { }
|
|
39
33
|
return defaults;
|
|
@@ -7,35 +7,50 @@ const common_1 = require("../common");
|
|
|
7
7
|
const defaults_1 = require("../common/defaults");
|
|
8
8
|
const exec_1 = require("../common/exec");
|
|
9
9
|
const files_1 = require("../common/files");
|
|
10
|
+
const security_1 = require("../common/security");
|
|
11
|
+
const readHwmonTemps = async () => {
|
|
12
|
+
const entries = [];
|
|
13
|
+
let mons = [];
|
|
14
|
+
try {
|
|
15
|
+
mons = (await (0, promises_1.readdir)('/sys/class/hwmon')).filter(security_1.isSafePathSegment).sort();
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
for (const mon of mons) {
|
|
19
|
+
const dir = `/sys/class/hwmon/${mon}`;
|
|
20
|
+
let labels = [];
|
|
21
|
+
try {
|
|
22
|
+
labels = (await (0, promises_1.readdir)(dir)).filter((file) => /^temp\d+_label$/.test(file)).sort();
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
for (const label of labels) {
|
|
26
|
+
const [name, value] = await Promise.all([(0, files_1.readSysfs)(`${dir}/${label}`), (0, files_1.readSysfs)(`${dir}/${label.replace(/_label$/, '_input')}`)]);
|
|
27
|
+
entries.push(`${name}___${value}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return entries;
|
|
31
|
+
};
|
|
10
32
|
const cpuTemperature = async () => {
|
|
11
33
|
await (0, common_1.nextTick)();
|
|
12
34
|
const result = (0, common_1.cloneObj)(defaults_1.initCpuTemperature);
|
|
13
35
|
let cpuThermal = null;
|
|
14
36
|
try {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (line.startsWith('pch') && lines2[i]) {
|
|
27
|
-
result.chipset = Math.round(Number.parseInt(lines2[i], 10) / 100) / 10;
|
|
28
|
-
}
|
|
29
|
-
if (cpuThermal === null && line.indexOf('cpu') !== -1 && lines2[i]) {
|
|
30
|
-
cpuThermal = Math.round(parseInt(lines2[i], 10) / 100) / 10;
|
|
31
|
-
}
|
|
37
|
+
const zones = (await (0, promises_1.readdir)('/sys/class/thermal')).filter((zone) => zone.startsWith('thermal_zone') && (0, security_1.isSafePathSegment)(zone)).sort();
|
|
38
|
+
for (const zone of zones) {
|
|
39
|
+
const [line, temp] = await Promise.all([(0, files_1.readSysfs)(`/sys/class/thermal/${zone}/type`), (0, files_1.readSysfs)(`/sys/class/thermal/${zone}/temp`)]);
|
|
40
|
+
if (line.startsWith('acpi') && temp) {
|
|
41
|
+
result.socket.push(Math.round(Number.parseInt(temp, 10) / 100) / 10);
|
|
42
|
+
}
|
|
43
|
+
if (line.startsWith('pch') && temp) {
|
|
44
|
+
result.chipset = Math.round(Number.parseInt(temp, 10) / 100) / 10;
|
|
45
|
+
}
|
|
46
|
+
if (cpuThermal === null && line.indexOf('cpu') !== -1 && temp) {
|
|
47
|
+
cpuThermal = Math.round(parseInt(temp, 10) / 100) / 10;
|
|
32
48
|
}
|
|
33
49
|
}
|
|
34
50
|
}
|
|
35
51
|
catch { }
|
|
36
|
-
const cmd = 'for mon in /sys/class/hwmon/hwmon*; do for label in "$mon"/temp*_label; do if [ -f $label ]; then value=${label%_*}_input; echo $(cat "$label")___$(cat "$value"); fi; done; done;';
|
|
37
52
|
try {
|
|
38
|
-
let
|
|
53
|
+
let stdout = (await readHwmonTemps()).join('\n');
|
|
39
54
|
const tdiePos = stdout.toLowerCase().indexOf('tdie');
|
|
40
55
|
if (tdiePos !== -1) {
|
|
41
56
|
stdout = stdout.substring(tdiePos);
|
package/dist/linux/cpu.js
CHANGED
|
@@ -8,6 +8,7 @@ const const_1 = require("../common/const");
|
|
|
8
8
|
const cpu_1 = require("../common/cpu");
|
|
9
9
|
const defaults_1 = require("../common/defaults");
|
|
10
10
|
const exec_1 = require("../common/exec");
|
|
11
|
+
const files_1 = require("../common/files");
|
|
11
12
|
const mappings_1 = require("../common/mappings");
|
|
12
13
|
const parse_1 = require("../common/parse");
|
|
13
14
|
const raspberry_1 = require("./../common/raspberry");
|
|
@@ -25,8 +26,9 @@ const cpu = async () => {
|
|
|
25
26
|
if ((0, node_os_1.cpus)()[0] && (0, node_os_1.cpus)()[0].model) {
|
|
26
27
|
modelline = (0, node_os_1.cpus)()[0].model;
|
|
27
28
|
}
|
|
28
|
-
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; lscpu;
|
|
29
|
+
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; lscpu; unset LC_ALL', const_1.execOptsLinux);
|
|
29
30
|
let lines = stdout.toString().split('\n');
|
|
31
|
+
lines.push(`Governor: ${await (0, files_1.readSysfs)('/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')}`);
|
|
30
32
|
modelline = (0, common_1.getValue)(lines, 'model name') || modelline;
|
|
31
33
|
modelline = (0, common_1.getValue)(lines, 'bios model name') || modelline;
|
|
32
34
|
modelline = (0, common_1.cleanString)(modelline);
|
|
@@ -4,9 +4,11 @@ exports.diskLayout = void 0;
|
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const const_1 = require("../common/const");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
|
+
const files_1 = require("../common/files");
|
|
7
8
|
const filesys_1 = require("../common/filesys");
|
|
8
9
|
const mappings_1 = require("../common/mappings");
|
|
9
10
|
const security_1 = require("../common/security");
|
|
11
|
+
const virtualBlockDevice = /^(ram|zram|loop|dm-|nbd|fd)\d*$/;
|
|
10
12
|
const diskLayout = async () => {
|
|
11
13
|
await (0, common_1.nextTick)();
|
|
12
14
|
const result = [];
|
|
@@ -29,10 +31,7 @@ const diskLayout = async () => {
|
|
|
29
31
|
item.fstype === null &&
|
|
30
32
|
item.parttype === null &&
|
|
31
33
|
item.path &&
|
|
32
|
-
item.path.
|
|
33
|
-
item.path.indexOf('/loop') !== 0 &&
|
|
34
|
-
item['disc-max'] &&
|
|
35
|
-
item['disc-max'] !== 0)));
|
|
34
|
+
!virtualBlockDevice.test(item.name || item.path.replace('/dev/', '')))));
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -42,7 +41,9 @@ const diskLayout = async () => {
|
|
|
42
41
|
const lines = (0, filesys_1.blkStdoutToObject)(stdout).split('\n');
|
|
43
42
|
const data = (0, filesys_1.parseLinuxBlk)(lines);
|
|
44
43
|
devices = data.filter((item) => {
|
|
45
|
-
return item.type === 'disk' &&
|
|
44
|
+
return (item.type === 'disk' &&
|
|
45
|
+
item.size > 0 &&
|
|
46
|
+
((item.model !== null && item.model !== '') || (item.mount === '' && item.label === '' && item.fsType === '' && !virtualBlockDevice.test(item.name || ''))));
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
catch { }
|
|
@@ -51,11 +52,7 @@ const diskLayout = async () => {
|
|
|
51
52
|
let mediumType = '';
|
|
52
53
|
const logical = (0, security_1.sanitizeShellString)(device.name || '', true);
|
|
53
54
|
const bsdName = '/dev/' + logical;
|
|
54
|
-
|
|
55
|
-
({ stdout } = await (0, exec_1.exec)('cat /sys/block/' + logical + '/queue/rotational 2>/dev/null', const_1.execOptsLinux));
|
|
56
|
-
mediumType = stdout.split('\n')[0];
|
|
57
|
-
}
|
|
58
|
-
catch { }
|
|
55
|
+
mediumType = (0, security_1.isSafePathSegment)(logical) ? await (0, files_1.readSysfs)(`/sys/block/${logical}/queue/rotational`) : '';
|
|
59
56
|
let interfaceType = device.tran ? device.tran.toUpperCase().trim() : '';
|
|
60
57
|
if (interfaceType === 'NVME') {
|
|
61
58
|
mediumType = '2';
|
package/dist/linux/disks-io.js
CHANGED
|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.disksIO = void 0;
|
|
4
4
|
const defaults_1 = require("../common/defaults");
|
|
5
5
|
const index_1 = require("../common/index");
|
|
6
|
-
const exec_1 = require("../common/exec");
|
|
7
6
|
const common_1 = require("../common");
|
|
8
7
|
const filesys_1 = require("../common/filesys");
|
|
9
|
-
const
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const files_1 = require("../common/files");
|
|
10
|
+
const security_1 = require("../common/security");
|
|
10
11
|
const disksIO = async () => {
|
|
11
12
|
await (0, common_1.nextTick)();
|
|
12
13
|
if ((filesys_1._disk_io && !filesys_1._disk_io.ms) || (filesys_1._disk_io && filesys_1._disk_io.ms && Date.now() - filesys_1._disk_io.ms >= 500)) {
|
|
@@ -17,14 +18,13 @@ const disksIO = async () => {
|
|
|
17
18
|
let wWaitTime = 0;
|
|
18
19
|
let tWaitTime = 0;
|
|
19
20
|
try {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const lines = stdout.split('\n');
|
|
21
|
+
const disks = (await (0, promises_1.readdir)('/sys/block')).filter((dev) => !/^(loop|ram|dm-|md|sr|fd|nbd)/.test(dev) && (0, security_1.isSafePathSegment)(dev));
|
|
22
|
+
const lines = await Promise.all(disks.map((dev) => (0, files_1.readSysfs)(`/sys/block/${dev}/stat`)));
|
|
23
23
|
lines.forEach(function (line) {
|
|
24
24
|
if (!line) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const stats = line.split(
|
|
27
|
+
const stats = line.trim().split(/\s+/);
|
|
28
28
|
rIO += (0, common_1.toInt)(stats[0]);
|
|
29
29
|
wIO += (0, common_1.toInt)(stats[4]);
|
|
30
30
|
rWaitTime += (0, common_1.toInt)(stats[3]);
|
|
@@ -46,9 +46,9 @@ const disksIO = async () => {
|
|
|
46
46
|
rIO_sec: filesys_1._disk_io.rIO_sec,
|
|
47
47
|
wIO_sec: filesys_1._disk_io.wIO_sec,
|
|
48
48
|
tIO_sec: filesys_1._disk_io.tIO_sec,
|
|
49
|
-
rWaitTime: filesys_1._disk_io.
|
|
50
|
-
wWaitTime: filesys_1._disk_io.
|
|
51
|
-
tWaitTime: filesys_1._disk_io.
|
|
49
|
+
rWaitTime: filesys_1._disk_io.rWaitTimeDelta,
|
|
50
|
+
wWaitTime: filesys_1._disk_io.wWaitTimeDelta,
|
|
51
|
+
tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
|
|
52
52
|
rWaitPercent: filesys_1._disk_io.rWaitPercent,
|
|
53
53
|
wWaitPercent: filesys_1._disk_io.wWaitPercent,
|
|
54
54
|
tWaitPercent: filesys_1._disk_io.tWaitPercent
|
package/dist/linux/displays.js
CHANGED
|
@@ -135,6 +135,38 @@ const parseLinesLinuxDisplays = (lines, depth) => {
|
|
|
135
135
|
currentDisplay.resolutionX !== null) {
|
|
136
136
|
displays.push(currentDisplay);
|
|
137
137
|
}
|
|
138
|
+
displays.forEach((display, i) => {
|
|
139
|
+
display.mirror = displays.some((other, j) => j !== i && other.positionX === display.positionX && other.positionY === display.positionY && other.currentResX === display.currentResX && other.currentResY === display.currentResY);
|
|
140
|
+
});
|
|
141
|
+
return displays;
|
|
142
|
+
};
|
|
143
|
+
const getWorkAreaLinux = async (displays) => {
|
|
144
|
+
try {
|
|
145
|
+
const { stdout } = await (0, exec_1.execSave)('xprop -root _NET_WORKAREA 2>/dev/null');
|
|
146
|
+
const values = (stdout.toString().split('=')[1] || '').split(',').map((value) => (0, common_1.toInt)(value));
|
|
147
|
+
const [areaX, areaY, areaWidth, areaHeight] = values;
|
|
148
|
+
if (values.length < 4 || !areaWidth || !areaHeight) {
|
|
149
|
+
return displays;
|
|
150
|
+
}
|
|
151
|
+
displays.forEach((display) => {
|
|
152
|
+
const width = display.currentResX || display.resolutionX;
|
|
153
|
+
const height = display.currentResY || display.resolutionY;
|
|
154
|
+
if (!width || !height) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const left = Math.max(display.positionX, areaX);
|
|
158
|
+
const top = Math.max(display.positionY, areaY);
|
|
159
|
+
const right = Math.min(display.positionX + width, areaX + areaWidth);
|
|
160
|
+
const bottom = Math.min(display.positionY + height, areaY + areaHeight);
|
|
161
|
+
if (right > left && bottom > top) {
|
|
162
|
+
display.workAreaResolutionX = right - left;
|
|
163
|
+
display.workAreaResolutionY = bottom - top;
|
|
164
|
+
display.workAreaPositionX = left;
|
|
165
|
+
display.workAreaPositionY = top;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch { }
|
|
138
170
|
return displays;
|
|
139
171
|
};
|
|
140
172
|
const displays = async () => {
|
|
@@ -156,6 +188,7 @@ const displays = async () => {
|
|
|
156
188
|
deviceName: '',
|
|
157
189
|
displayId: null,
|
|
158
190
|
main: true,
|
|
191
|
+
mirror: false,
|
|
159
192
|
builtin: false,
|
|
160
193
|
connection: 'HDMI',
|
|
161
194
|
sizeX: null,
|
|
@@ -167,7 +200,12 @@ const displays = async () => {
|
|
|
167
200
|
currentResY: null,
|
|
168
201
|
positionX: 0,
|
|
169
202
|
positionY: 0,
|
|
170
|
-
|
|
203
|
+
workAreaResolutionX: null,
|
|
204
|
+
workAreaResolutionY: null,
|
|
205
|
+
workAreaPositionX: null,
|
|
206
|
+
workAreaPositionY: null,
|
|
207
|
+
currentRefreshRate: null,
|
|
208
|
+
scale: null
|
|
171
209
|
});
|
|
172
210
|
}
|
|
173
211
|
}
|
|
@@ -181,7 +219,7 @@ const displays = async () => {
|
|
|
181
219
|
try {
|
|
182
220
|
({ stdout } = await (0, exec_1.exec)('xrandr --verbose 2>/dev/null', const_1.execOptsLinux));
|
|
183
221
|
const lines = stdout.toString().split('\n');
|
|
184
|
-
return parseLinesLinuxDisplays(lines, depth);
|
|
222
|
+
return await getWorkAreaLinux(parseLinesLinuxDisplays(lines, depth));
|
|
185
223
|
}
|
|
186
224
|
catch { }
|
|
187
225
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fans = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const files_1 = require("../common/files");
|
|
7
|
+
const security_1 = require("../common/security");
|
|
8
|
+
const toNumber = (value) => {
|
|
9
|
+
const result = Number.parseFloat(value);
|
|
10
|
+
return Number.isNaN(result) ? null : result;
|
|
11
|
+
};
|
|
12
|
+
const pwmToPercent = (value) => {
|
|
13
|
+
const raw = toNumber(value);
|
|
14
|
+
return raw === null ? null : Math.round((raw / 255) * 100);
|
|
15
|
+
};
|
|
16
|
+
const hwmonFans = async (hwmonPath) => {
|
|
17
|
+
const fans = [];
|
|
18
|
+
let nodes = [];
|
|
19
|
+
try {
|
|
20
|
+
nodes = (await (0, promises_1.readdir)(hwmonPath)).filter(security_1.isSafePathSegment);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return fans;
|
|
24
|
+
}
|
|
25
|
+
for (const node of nodes) {
|
|
26
|
+
const entries = [];
|
|
27
|
+
try {
|
|
28
|
+
entries.push(...(await (0, promises_1.readdir)(`${hwmonPath}/${node}`)));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const source = (await (0, files_1.readSysfs)(`${hwmonPath}/${node}/name`)) || node;
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
const match = /^fan(\d+)_input$/.exec(entry);
|
|
36
|
+
if (!match) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const index = match[1];
|
|
40
|
+
const rpm = toNumber(await (0, files_1.readSysfs)(`${hwmonPath}/${node}/fan${index}_input`));
|
|
41
|
+
if (rpm === null) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
fans.push({
|
|
45
|
+
id: `${node}/fan${index}`,
|
|
46
|
+
label: (await (0, files_1.readSysfs)(`${hwmonPath}/${node}/fan${index}_label`)) || null,
|
|
47
|
+
rpm,
|
|
48
|
+
pwm: pwmToPercent(await (0, files_1.readSysfs)(`${hwmonPath}/${node}/pwm${index}`)),
|
|
49
|
+
source
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return fans;
|
|
54
|
+
};
|
|
55
|
+
const coolingDeviceFans = async (thermalPath) => {
|
|
56
|
+
const fans = [];
|
|
57
|
+
let nodes = [];
|
|
58
|
+
try {
|
|
59
|
+
nodes = (await (0, promises_1.readdir)(thermalPath)).filter((entry) => entry.startsWith('cooling_device') && (0, security_1.isSafePathSegment)(entry));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return fans;
|
|
63
|
+
}
|
|
64
|
+
for (const node of nodes) {
|
|
65
|
+
const type = await (0, files_1.readSysfs)(`${thermalPath}/${node}/type`);
|
|
66
|
+
if (!type.toLowerCase().includes('fan')) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const current = toNumber(await (0, files_1.readSysfs)(`${thermalPath}/${node}/cur_state`));
|
|
70
|
+
const max = toNumber(await (0, files_1.readSysfs)(`${thermalPath}/${node}/max_state`));
|
|
71
|
+
if (current === null || !max) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
fans.push({
|
|
75
|
+
id: node,
|
|
76
|
+
label: null,
|
|
77
|
+
rpm: null,
|
|
78
|
+
pwm: Math.round((current / max) * 100),
|
|
79
|
+
source: type
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return fans;
|
|
83
|
+
};
|
|
84
|
+
const fans = async (hwmonPath = '/sys/class/hwmon', thermalPath = '/sys/class/thermal') => {
|
|
85
|
+
await (0, common_1.nextTick)();
|
|
86
|
+
const result = await hwmonFans(hwmonPath);
|
|
87
|
+
if (!result.length) {
|
|
88
|
+
return coolingDeviceFans(thermalPath);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
exports.fans = fans;
|