systeminformation 5.9.7 → 5.9.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 CHANGED
@@ -163,6 +163,7 @@ Full function reference with examples can be found at [https://systeminformation
163
163
  | | version | X | X | X | X | | version |
164
164
  | | releaseDate | X | X | | X | | release date |
165
165
  | | revision | X | X | | X | | revision |
166
+ | | serial | X | | | X | | serial |
166
167
  | si.baseboard(cb) | {...} | X | X | X | X | | baseboard information |
167
168
  | | manufacturer | X | X | X | X | | e.g. 'ASUS' |
168
169
  | | model | X | X | X | X | | model / product name |
@@ -888,6 +889,8 @@ To be able to measure temperature on macOS I created a little additional package
888
889
  in NPM with `optionalDependencies` I unfortunately was getting unexpected warnings on other platforms.
889
890
  So I decided to drop this optional dependency for macOS - so by default, you will not get correct values.
890
891
 
892
+ This additional package will unfortunately NOT work on Apple Silicon M1 machines.
893
+
891
894
  But if you need to detect macOS temperature just run the following additional
892
895
  installation command:
893
896
 
@@ -976,6 +979,8 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
976
979
  - Miłosz Dźwigała [mily20001](https://github.com/mily20001)
977
980
  - cconley717 [cconley717](https://github.com/cconley717)
978
981
  - Maria Camila Cubides [MariaCamilaCubides](https://github.com/MariaCamilaCubides)
982
+ - Aleksander Krasnicki [plakak](https://github.com/plakak)
983
+ - Alexis Tyler [OmgImAlexis](https://github.com/OmgImAlexis)
979
984
 
980
985
  OSX Temperature: credits here are going to:
981
986
 
package/lib/audio.js CHANGED
@@ -1,219 +1,219 @@
1
- 'use strict';
2
- // @ts-check
3
- // ==================================================================================
4
- // audio.js
5
- // ----------------------------------------------------------------------------------
6
- // Description: System Information - library
7
- // for Node.js
8
- // Copyright: (c) 2014 - 2021
9
- // Author: Sebastian Hildebrandt
10
- // ----------------------------------------------------------------------------------
11
- // License: MIT
12
- // ==================================================================================
13
- // 16. audio
14
- // ----------------------------------------------------------------------------------
15
-
16
- const exec = require('child_process').exec;
17
- const execSync = require('child_process').execSync;
18
- const util = require('./util');
19
- // const fs = require('fs');
20
-
21
- let _platform = process.platform;
22
-
23
- const _linux = (_platform === 'linux');
24
- const _darwin = (_platform === 'darwin');
25
- const _windows = (_platform === 'win32');
26
- const _freebsd = (_platform === 'freebsd');
27
- const _openbsd = (_platform === 'openbsd');
28
- const _netbsd = (_platform === 'netbsd');
29
- const _sunos = (_platform === 'sunos');
30
-
31
- function parseAudioType(str, input, output) {
32
- let result = '';
33
-
34
- if (str.indexOf('speak') >= 0) { result = 'Speaker'; }
35
- if (str.indexOf('laut') >= 0) { result = 'Speaker'; }
36
- if (str.indexOf('loud') >= 0) { result = 'Speaker'; }
37
- if (str.indexOf('head') >= 0) { result = 'Headset'; }
38
- if (str.indexOf('mic') >= 0) { result = 'Microphone'; }
39
- if (str.indexOf('mikr') >= 0) { result = 'Microphone'; }
40
- if (str.indexOf('phone') >= 0) { result = 'Phone'; }
41
- if (str.indexOf('controll') >= 0) { result = 'Controller'; }
42
- if (str.indexOf('line o') >= 0) { result = 'Line Out'; }
43
- if (str.indexOf('digital o') >= 0) { result = 'Digital Out'; }
44
-
45
- if (!result && output) {
46
- result = 'Speaker';
47
- } else if (!result && input) {
48
- result = 'Microphone';
49
- }
50
- return result;
51
- }
52
-
53
-
54
- function getLinuxAudioPci() {
55
- let cmd = 'lspci -v 2>/dev/null';
56
- let result = [];
57
- try {
58
- const parts = execSync(cmd).toString().split('\n\n');
59
- for (let i = 0; i < parts.length; i++) {
60
- const lines = parts[i].split('\n');
61
- if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
62
- const audio = {};
63
- audio.slotId = lines[0].split(' ')[0];
64
- audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true);
65
- result.push(audio);
66
- }
67
- }
68
- return result;
69
- } catch (e) {
70
- return result;
71
- }
72
- }
73
-
74
- function parseLinuxAudioPciMM(lines, audioPCI) {
75
- const result = {};
76
- const slotId = util.getValue(lines, 'Slot');
77
-
78
- const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId; });
79
-
80
- result.id = slotId;
81
- result.name = util.getValue(lines, 'SDevice');
82
- // result.type = util.getValue(lines, 'Class');
83
- result.manufacturer = util.getValue(lines, 'SVendor');
84
- result.revision = util.getValue(lines, 'Rev');
85
- result.driver = pciMatch && pciMatch.length === 1 && pciMatch[0].driver ? pciMatch[0].driver : '';
86
- result.default = null;
87
- result.channel = 'PCIe';
88
- result.type = parseAudioType(result.name, null, null);
89
- result.in = null;
90
- result.out = null;
91
- result.status = 'online';
92
-
93
- return result;
94
- }
95
-
96
- function parseDarwinChannel(str) {
97
- let result = '';
98
-
99
- if (str.indexOf('builtin') >= 0) { result = 'Built-In'; }
100
- if (str.indexOf('extern') >= 0) { result = 'Audio-Jack'; }
101
- if (str.indexOf('hdmi') >= 0) { result = 'HDMI'; }
102
- if (str.indexOf('displayport') >= 0) { result = 'Display-Port'; }
103
- if (str.indexOf('usb') >= 0) { result = 'USB'; }
104
- if (str.indexOf('pci') >= 0) { result = 'PCIe'; }
105
-
106
- return result;
107
- }
108
-
109
- function parseDarwinAudio(audioObject, id) {
110
- const result = {};
111
- const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
112
-
113
- result.id = id;
114
- result.name = audioObject._name;
115
- result.manufacturer = audioObject.coreaudio_device_manufacturer;
116
- result.revision = null;
117
- result.driver = null;
118
- result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
119
- result.channel = parseDarwinChannel(channelStr);
120
- result.type = parseAudioType(result.name, !!(audioObject.coreaudio_device_input || ''), !!(audioObject.coreaudio_device_output || ''));
121
- result.in = !!(audioObject.coreaudio_device_input || '');
122
- result.out = !!(audioObject.coreaudio_device_output || '');
123
- result.status = 'online';
124
-
125
- return result;
126
- }
127
-
128
- function parseWindowsAudio(lines) {
129
- const result = {};
130
- const status = util.getValue(lines, 'StatusInfo', '=');
131
- // const description = util.getValue(lines, 'Description', '=');
132
-
133
- result.id = util.getValue(lines, 'DeviceID', '='); // PNPDeviceID??
134
- result.name = util.getValue(lines, 'name', '=');
135
- result.manufacturer = util.getValue(lines, 'manufacturer', '=');
136
- result.revision = null;
137
- result.driver = null;
138
- result.default = null;
139
- result.channel = null;
140
- result.type = parseAudioType(result.name, null, null);
141
- result.in = null;
142
- result.out = null;
143
- result.status = status;
144
-
145
- return result;
146
- }
147
-
148
- function audio(callback) {
149
-
150
- return new Promise((resolve) => {
151
- process.nextTick(() => {
152
- let result = [];
153
- if (_linux || _freebsd || _openbsd || _netbsd) {
154
- let cmd = 'lspci -vmm 2>/dev/null';
155
- exec(cmd, function (error, stdout) {
156
- // PCI
157
- if (!error) {
158
- const audioPCI = getLinuxAudioPci();
159
- const parts = stdout.toString().split('\n\n');
160
- for (let i = 0; i < parts.length; i++) {
161
- const lines = parts[i].split('\n');
162
- if (util.getValue(lines, 'class', ':', true).toLowerCase().indexOf('audio') >= 0) {
163
- const audio = parseLinuxAudioPciMM(lines, audioPCI);
164
- result.push(audio);
165
- }
166
- }
167
- }
168
- if (callback) {
169
- callback(result);
170
- }
171
- resolve(result);
172
- });
173
- }
174
- if (_darwin) {
175
- let cmd = 'system_profiler SPAudioDataType -json';
176
- exec(cmd, function (error, stdout) {
177
- if (!error) {
178
- try {
179
- const outObj = JSON.parse(stdout.toString());
180
- if (outObj.SPAudioDataType && outObj.SPAudioDataType.length && outObj.SPAudioDataType[0] && outObj.SPAudioDataType[0]['_items'] && outObj.SPAudioDataType[0]['_items'].length) {
181
- for (let i = 0; i < outObj.SPAudioDataType[0]['_items'].length; i++) {
182
- const audio = parseDarwinAudio(outObj.SPAudioDataType[0]['_items'][i], i);
183
- result.push(audio);
184
- }
185
- }
186
- } catch (e) {
187
- util.noop();
188
- }
189
- }
190
- if (callback) {
191
- callback(result);
192
- }
193
- resolve(result);
194
- });
195
- }
196
- if (_windows) {
197
- util.wmic('path Win32_SoundDevice get /value', function (error, stdout) {
198
- if (!error) {
199
- const parts = stdout.toString().split(/\n\s*\n/);
200
- for (let i = 0; i < parts.length; i++) {
201
- if (util.getValue(parts[i].split('\n'), 'name', '=')) {
202
- result.push(parseWindowsAudio(parts[i].split('\n')));
203
- }
204
- }
205
- }
206
- if (callback) {
207
- callback(result);
208
- }
209
- resolve(result);
210
- });
211
- }
212
- if (_sunos) {
213
- resolve(null);
214
- }
215
- });
216
- });
217
- }
218
-
219
- exports.audio = audio;
1
+ 'use strict';
2
+ // @ts-check
3
+ // ==================================================================================
4
+ // audio.js
5
+ // ----------------------------------------------------------------------------------
6
+ // Description: System Information - library
7
+ // for Node.js
8
+ // Copyright: (c) 2014 - 2021
9
+ // Author: Sebastian Hildebrandt
10
+ // ----------------------------------------------------------------------------------
11
+ // License: MIT
12
+ // ==================================================================================
13
+ // 16. audio
14
+ // ----------------------------------------------------------------------------------
15
+
16
+ const exec = require('child_process').exec;
17
+ const execSync = require('child_process').execSync;
18
+ const util = require('./util');
19
+ // const fs = require('fs');
20
+
21
+ let _platform = process.platform;
22
+
23
+ const _linux = (_platform === 'linux');
24
+ const _darwin = (_platform === 'darwin');
25
+ const _windows = (_platform === 'win32');
26
+ const _freebsd = (_platform === 'freebsd');
27
+ const _openbsd = (_platform === 'openbsd');
28
+ const _netbsd = (_platform === 'netbsd');
29
+ const _sunos = (_platform === 'sunos');
30
+
31
+ function parseAudioType(str, input, output) {
32
+ let result = '';
33
+
34
+ if (str.indexOf('speak') >= 0) { result = 'Speaker'; }
35
+ if (str.indexOf('laut') >= 0) { result = 'Speaker'; }
36
+ if (str.indexOf('loud') >= 0) { result = 'Speaker'; }
37
+ if (str.indexOf('head') >= 0) { result = 'Headset'; }
38
+ if (str.indexOf('mic') >= 0) { result = 'Microphone'; }
39
+ if (str.indexOf('mikr') >= 0) { result = 'Microphone'; }
40
+ if (str.indexOf('phone') >= 0) { result = 'Phone'; }
41
+ if (str.indexOf('controll') >= 0) { result = 'Controller'; }
42
+ if (str.indexOf('line o') >= 0) { result = 'Line Out'; }
43
+ if (str.indexOf('digital o') >= 0) { result = 'Digital Out'; }
44
+
45
+ if (!result && output) {
46
+ result = 'Speaker';
47
+ } else if (!result && input) {
48
+ result = 'Microphone';
49
+ }
50
+ return result;
51
+ }
52
+
53
+
54
+ function getLinuxAudioPci() {
55
+ let cmd = 'lspci -v 2>/dev/null';
56
+ let result = [];
57
+ try {
58
+ const parts = execSync(cmd).toString().split('\n\n');
59
+ for (let i = 0; i < parts.length; i++) {
60
+ const lines = parts[i].split('\n');
61
+ if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
62
+ const audio = {};
63
+ audio.slotId = lines[0].split(' ')[0];
64
+ audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true);
65
+ result.push(audio);
66
+ }
67
+ }
68
+ return result;
69
+ } catch (e) {
70
+ return result;
71
+ }
72
+ }
73
+
74
+ function parseLinuxAudioPciMM(lines, audioPCI) {
75
+ const result = {};
76
+ const slotId = util.getValue(lines, 'Slot');
77
+
78
+ const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId; });
79
+
80
+ result.id = slotId;
81
+ result.name = util.getValue(lines, 'SDevice');
82
+ // result.type = util.getValue(lines, 'Class');
83
+ result.manufacturer = util.getValue(lines, 'SVendor');
84
+ result.revision = util.getValue(lines, 'Rev');
85
+ result.driver = pciMatch && pciMatch.length === 1 && pciMatch[0].driver ? pciMatch[0].driver : '';
86
+ result.default = null;
87
+ result.channel = 'PCIe';
88
+ result.type = parseAudioType(result.name, null, null);
89
+ result.in = null;
90
+ result.out = null;
91
+ result.status = 'online';
92
+
93
+ return result;
94
+ }
95
+
96
+ function parseDarwinChannel(str) {
97
+ let result = '';
98
+
99
+ if (str.indexOf('builtin') >= 0) { result = 'Built-In'; }
100
+ if (str.indexOf('extern') >= 0) { result = 'Audio-Jack'; }
101
+ if (str.indexOf('hdmi') >= 0) { result = 'HDMI'; }
102
+ if (str.indexOf('displayport') >= 0) { result = 'Display-Port'; }
103
+ if (str.indexOf('usb') >= 0) { result = 'USB'; }
104
+ if (str.indexOf('pci') >= 0) { result = 'PCIe'; }
105
+
106
+ return result;
107
+ }
108
+
109
+ function parseDarwinAudio(audioObject, id) {
110
+ const result = {};
111
+ const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
112
+
113
+ result.id = id;
114
+ result.name = audioObject._name;
115
+ result.manufacturer = audioObject.coreaudio_device_manufacturer;
116
+ result.revision = null;
117
+ result.driver = null;
118
+ result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
119
+ result.channel = parseDarwinChannel(channelStr);
120
+ result.type = parseAudioType(result.name, !!(audioObject.coreaudio_device_input || ''), !!(audioObject.coreaudio_device_output || ''));
121
+ result.in = !!(audioObject.coreaudio_device_input || '');
122
+ result.out = !!(audioObject.coreaudio_device_output || '');
123
+ result.status = 'online';
124
+
125
+ return result;
126
+ }
127
+
128
+ function parseWindowsAudio(lines) {
129
+ const result = {};
130
+ const status = util.getValue(lines, 'StatusInfo', ':');
131
+ // const description = util.getValue(lines, 'Description', ':');
132
+
133
+ result.id = util.getValue(lines, 'DeviceID', ':'); // PNPDeviceID??
134
+ result.name = util.getValue(lines, 'name', ':');
135
+ result.manufacturer = util.getValue(lines, 'manufacturer', ':');
136
+ result.revision = null;
137
+ result.driver = null;
138
+ result.default = null;
139
+ result.channel = null;
140
+ result.type = parseAudioType(result.name, null, null);
141
+ result.in = null;
142
+ result.out = null;
143
+ result.status = status;
144
+
145
+ return result;
146
+ }
147
+
148
+ function audio(callback) {
149
+
150
+ return new Promise((resolve) => {
151
+ process.nextTick(() => {
152
+ let result = [];
153
+ if (_linux || _freebsd || _openbsd || _netbsd) {
154
+ let cmd = 'lspci -vmm 2>/dev/null';
155
+ exec(cmd, function (error, stdout) {
156
+ // PCI
157
+ if (!error) {
158
+ const audioPCI = getLinuxAudioPci();
159
+ const parts = stdout.toString().split('\n\n');
160
+ for (let i = 0; i < parts.length; i++) {
161
+ const lines = parts[i].split('\n');
162
+ if (util.getValue(lines, 'class', ':', true).toLowerCase().indexOf('audio') >= 0) {
163
+ const audio = parseLinuxAudioPciMM(lines, audioPCI);
164
+ result.push(audio);
165
+ }
166
+ }
167
+ }
168
+ if (callback) {
169
+ callback(result);
170
+ }
171
+ resolve(result);
172
+ });
173
+ }
174
+ if (_darwin) {
175
+ let cmd = 'system_profiler SPAudioDataType -json';
176
+ exec(cmd, function (error, stdout) {
177
+ if (!error) {
178
+ try {
179
+ const outObj = JSON.parse(stdout.toString());
180
+ if (outObj.SPAudioDataType && outObj.SPAudioDataType.length && outObj.SPAudioDataType[0] && outObj.SPAudioDataType[0]['_items'] && outObj.SPAudioDataType[0]['_items'].length) {
181
+ for (let i = 0; i < outObj.SPAudioDataType[0]['_items'].length; i++) {
182
+ const audio = parseDarwinAudio(outObj.SPAudioDataType[0]['_items'][i], i);
183
+ result.push(audio);
184
+ }
185
+ }
186
+ } catch (e) {
187
+ util.noop();
188
+ }
189
+ }
190
+ if (callback) {
191
+ callback(result);
192
+ }
193
+ resolve(result);
194
+ });
195
+ }
196
+ if (_windows) {
197
+ util.powerShell('Get-WmiObject Win32_SoundDevice | fl *').then((stdout, error) => {
198
+ if (!error) {
199
+ const parts = stdout.toString().split(/\n\s*\n/);
200
+ for (let i = 0; i < parts.length; i++) {
201
+ if (util.getValue(parts[i].split('\n'), 'name', ':')) {
202
+ result.push(parseWindowsAudio(parts[i].split('\n')));
203
+ }
204
+ }
205
+ }
206
+ if (callback) {
207
+ callback(result);
208
+ }
209
+ resolve(result);
210
+ });
211
+ }
212
+ if (_sunos) {
213
+ resolve(null);
214
+ }
215
+ });
216
+ });
217
+ }
218
+
219
+ exports.audio = audio;