about-system 0.0.2 → 0.0.4
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/about-system.js +104 -24
- package/package.json +3 -5
package/about-system.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* Network info (ip, city, domain, isp) is fetched from ipinfo.io
|
|
16
16
|
* only if needed.
|
|
17
17
|
*
|
|
18
|
-
* Author:
|
|
18
|
+
* Author: vtempest
|
|
19
19
|
* Updated: 2025-09-01
|
|
20
20
|
* License: MIT
|
|
21
21
|
*/
|
|
@@ -52,12 +52,11 @@ const CACHE_DURATION = {
|
|
|
52
52
|
|
|
53
53
|
// Default settings
|
|
54
54
|
const DEFAULT_SETTINGS = {
|
|
55
|
-
version: "1.0.0",
|
|
56
55
|
display_order: [
|
|
57
|
-
['user', 'hostname', 'os', '
|
|
56
|
+
['user', 'hostname', 'os', 'device', 'kernel', 'cpu', 'gpu', ],
|
|
58
57
|
['disk_used', 'ram_used', 'top_process', 'uptime', 'temperature', 'battery', 'load_average'],
|
|
59
58
|
['ip', 'iplocal', 'city', 'domain', 'isp'],
|
|
60
|
-
['shell', 'pacman', 'ports', '
|
|
59
|
+
['shell', 'pacman', 'ports', 'services_running', 'containers']
|
|
61
60
|
],
|
|
62
61
|
colors: {
|
|
63
62
|
user: "red",
|
|
@@ -71,13 +70,13 @@ const DEFAULT_SETTINGS = {
|
|
|
71
70
|
city: "green",
|
|
72
71
|
domain: "gray",
|
|
73
72
|
isp: "lightblue",
|
|
74
|
-
os: "
|
|
73
|
+
os: "gray",
|
|
75
74
|
cpu: "orange",
|
|
76
75
|
gpu: "yellow",
|
|
77
|
-
device: "
|
|
76
|
+
device: "yellow",
|
|
78
77
|
kernel: "green",
|
|
79
78
|
shell: "orange",
|
|
80
|
-
pacman: "
|
|
79
|
+
pacman: "multicolor",
|
|
81
80
|
ports: "multicolor",
|
|
82
81
|
containers: "green",
|
|
83
82
|
memory_available: "blue",
|
|
@@ -104,9 +103,20 @@ const DEFAULT_SETTINGS = {
|
|
|
104
103
|
show_emojis: true,
|
|
105
104
|
compact_mode: false,
|
|
106
105
|
separator: "\n",
|
|
107
|
-
max_width: 120,
|
|
108
106
|
multiline: true,
|
|
109
|
-
group_similar: true
|
|
107
|
+
group_similar: true,
|
|
108
|
+
single_line: false,
|
|
109
|
+
line_wrap_length: (() => {
|
|
110
|
+
try {
|
|
111
|
+
const { execSync } = require('child_process');
|
|
112
|
+
const size = execSync('stty size', { encoding: 'utf8' }).trim();
|
|
113
|
+
const cols = parseInt(size.split(' ')[1]);
|
|
114
|
+
console.log(cols)
|
|
115
|
+
return cols > 0 ? cols : 100; // fallback to 100 if stty fails
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return 100; // fallback to 100 if stty is not available
|
|
118
|
+
}
|
|
119
|
+
})()
|
|
110
120
|
},
|
|
111
121
|
advanced: {
|
|
112
122
|
debug: false,
|
|
@@ -475,6 +485,9 @@ const infoFunctions = {
|
|
|
475
485
|
setCachedValue(this.cache, 'cpu', '');
|
|
476
486
|
return '';
|
|
477
487
|
}
|
|
488
|
+
|
|
489
|
+
//remove "with ..." from cpuName
|
|
490
|
+
cpuName = cpuName.replace(/with .*/, '');
|
|
478
491
|
|
|
479
492
|
const color = colors[settings.colors.cpu] || colors.orange;
|
|
480
493
|
const emoji = settings.display.show_emojis ? '📈 ' : '';
|
|
@@ -1114,33 +1127,79 @@ async function displaySystemInfo() {
|
|
|
1114
1127
|
context.ipInfo = cachedIPInfo;
|
|
1115
1128
|
}
|
|
1116
1129
|
|
|
1130
|
+
// If single line mode is enabled, flatten everything into one line
|
|
1131
|
+
if (settings.display.single_line) {
|
|
1132
|
+
const allItems = [];
|
|
1133
|
+
|
|
1134
|
+
for (const group of settings.display_order) {
|
|
1135
|
+
for (const key of group) {
|
|
1136
|
+
if (infoFunctions[key]) {
|
|
1137
|
+
try {
|
|
1138
|
+
const info = await infoFunctions[key].call(context, settings);
|
|
1139
|
+
if (info && info.trim()) {
|
|
1140
|
+
allItems.push(info);
|
|
1141
|
+
}
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
if (settings.advanced.debug) {
|
|
1144
|
+
console.error(`Error getting ${key}:`, error.message);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
if (allItems.length > 0) {
|
|
1152
|
+
const singleLine = allItems.join(' ');
|
|
1153
|
+
console.log(singleLine + colors.reset);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
// Save cache and return early
|
|
1157
|
+
saveCache(cache);
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// Normal multi-line grouped display with intelligent wrapping
|
|
1117
1162
|
const lines = [];
|
|
1163
|
+
let currentLine = '';
|
|
1164
|
+
const maxLineLength = settings.display.line_wrap_length || 120;
|
|
1118
1165
|
|
|
1119
1166
|
for (const group of settings.display_order) {
|
|
1120
|
-
const lineItems = [];
|
|
1121
|
-
|
|
1122
1167
|
for (const key of group) {
|
|
1123
1168
|
if (infoFunctions[key]) {
|
|
1124
1169
|
try {
|
|
1125
1170
|
const info = await infoFunctions[key].call(context, settings);
|
|
1126
1171
|
if (info && info.trim()) {
|
|
1127
|
-
|
|
1172
|
+
// Remove ANSI color codes to get actual text length
|
|
1173
|
+
const infoLength = info.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
1174
|
+
const currentLineLength = currentLine.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
1175
|
+
|
|
1176
|
+
// If adding this item would exceed the line length, start a new line
|
|
1177
|
+
if (currentLine && (currentLineLength + infoLength + 1) > maxLineLength) {
|
|
1178
|
+
lines.push(currentLine);
|
|
1179
|
+
currentLine = info;
|
|
1180
|
+
} else {
|
|
1181
|
+
// Add to current line
|
|
1182
|
+
if (currentLine) {
|
|
1183
|
+
currentLine += ' ' + info;
|
|
1184
|
+
} else {
|
|
1185
|
+
currentLine = info;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1128
1188
|
}
|
|
1129
1189
|
} catch (error) {
|
|
1130
1190
|
if (settings.advanced.debug) {
|
|
1131
1191
|
console.error(`Error getting ${key}:`, error.message);
|
|
1132
1192
|
}
|
|
1133
|
-
// Continue on errors unless debug mode
|
|
1134
1193
|
}
|
|
1135
1194
|
} else if (settings.advanced.debug) {
|
|
1136
1195
|
console.error(`Unknown info function: ${key}`);
|
|
1137
1196
|
}
|
|
1138
1197
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// Add the last line if it has content
|
|
1201
|
+
if (currentLine) {
|
|
1202
|
+
lines.push(currentLine);
|
|
1144
1203
|
}
|
|
1145
1204
|
|
|
1146
1205
|
// Show offline message if no network and IP info was requested but failed
|
|
@@ -1351,6 +1410,22 @@ async function main() {
|
|
|
1351
1410
|
return;
|
|
1352
1411
|
}
|
|
1353
1412
|
|
|
1413
|
+
// Check for --single-line argument
|
|
1414
|
+
if (args.includes('--single-line')) {
|
|
1415
|
+
const settings = loadSettings();
|
|
1416
|
+
settings.display.single_line = true;
|
|
1417
|
+
await displaySystemInfo();
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// Check for --multi-line argument
|
|
1422
|
+
if (args.includes('--multi-line')) {
|
|
1423
|
+
const settings = loadSettings();
|
|
1424
|
+
settings.display.single_line = false;
|
|
1425
|
+
await displaySystemInfo();
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1354
1429
|
// Check for --help argument
|
|
1355
1430
|
if (args.includes('--help') || args.includes('-h')) {
|
|
1356
1431
|
console.log(`
|
|
@@ -1393,13 +1468,18 @@ Available colors:
|
|
|
1393
1468
|
(use "multicolor" for ports to get rainbow effect)
|
|
1394
1469
|
|
|
1395
1470
|
Display Format:
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
-
|
|
1400
|
-
|
|
1471
|
+
Default: Single-line output with all information on one continuous line
|
|
1472
|
+
👤 user 🏠 hostname ⚡ OS 📈 CPU 🎮 GPU 💻 device 🔧 kernel 📁 90% 💾 2GB ...
|
|
1473
|
+
|
|
1474
|
+
Multi-line Mode: Use --multi-line or --set display.single_line false
|
|
1475
|
+
Intelligent line wrapping breaks lines at ~100 characters (configurable):
|
|
1476
|
+
- Respects word boundaries and doesn't break in the middle of items
|
|
1477
|
+
- Dynamically arranges items based on actual character length
|
|
1478
|
+
- Ignores ANSI color codes when calculating line length
|
|
1479
|
+
|
|
1480
|
+
Configure line wrap length: --set display.line_wrap_length 80
|
|
1401
1481
|
|
|
1402
|
-
To customize
|
|
1482
|
+
To customize item order, modify display_order as an array of arrays:
|
|
1403
1483
|
--set display_order '[["user","hostname","os"],["disk_used","ram_used"],["ip","city"],["shell","pacman"]]'
|
|
1404
1484
|
|
|
1405
1485
|
Linux-specific features:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "about-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A Node.js script to display key system information with emojis. Cross-platform support for Windows, macOS, and Linux with customizable output and caching.",
|
|
5
5
|
"main": "about-system.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,9 +32,6 @@
|
|
|
32
32
|
],
|
|
33
33
|
"author": "vtempest",
|
|
34
34
|
"license": "MIT",
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=12.0.0"
|
|
37
|
-
},
|
|
38
35
|
"repository": {
|
|
39
36
|
"type": "git",
|
|
40
37
|
"url": "https://github.com/vtempest/server-shell-setup.git"
|
|
@@ -48,7 +45,8 @@
|
|
|
48
45
|
"os": [
|
|
49
46
|
"win32",
|
|
50
47
|
"darwin",
|
|
51
|
-
"linux"
|
|
48
|
+
"linux",
|
|
49
|
+
"android"
|
|
52
50
|
],
|
|
53
51
|
"preferGlobal": true,
|
|
54
52
|
"directories": {
|