about-system 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/about-system.js +92 -22
  2. package/package.json +1 -1
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: Adapted from vtempest bash version (2022-25)
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', 'cpu', 'gpu', 'device', 'kernel'],
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', 'containers', 'services_running']
59
+ ['shell', 'pacman', 'ports', 'services_running', 'containers']
61
60
  ],
62
61
  colors: {
63
62
  user: "red",
@@ -77,7 +76,7 @@ const DEFAULT_SETTINGS = {
77
76
  device: "blue",
78
77
  kernel: "green",
79
78
  shell: "orange",
80
- pacman: "cyan",
79
+ pacman: "multicolor",
81
80
  ports: "multicolor",
82
81
  containers: "green",
83
82
  memory_available: "blue",
@@ -104,9 +103,10 @@ 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: 80
110
110
  },
111
111
  advanced: {
112
112
  debug: false,
@@ -475,6 +475,9 @@ const infoFunctions = {
475
475
  setCachedValue(this.cache, 'cpu', '');
476
476
  return '';
477
477
  }
478
+
479
+ //remove "with ..." from cpuName
480
+ cpuName = cpuName.replace(/with .*/, '');
478
481
 
479
482
  const color = colors[settings.colors.cpu] || colors.orange;
480
483
  const emoji = settings.display.show_emojis ? '📈 ' : '';
@@ -1114,33 +1117,79 @@ async function displaySystemInfo() {
1114
1117
  context.ipInfo = cachedIPInfo;
1115
1118
  }
1116
1119
 
1120
+ // If single line mode is enabled, flatten everything into one line
1121
+ if (settings.display.single_line) {
1122
+ const allItems = [];
1123
+
1124
+ for (const group of settings.display_order) {
1125
+ for (const key of group) {
1126
+ if (infoFunctions[key]) {
1127
+ try {
1128
+ const info = await infoFunctions[key].call(context, settings);
1129
+ if (info && info.trim()) {
1130
+ allItems.push(info);
1131
+ }
1132
+ } catch (error) {
1133
+ if (settings.advanced.debug) {
1134
+ console.error(`Error getting ${key}:`, error.message);
1135
+ }
1136
+ }
1137
+ }
1138
+ }
1139
+ }
1140
+
1141
+ if (allItems.length > 0) {
1142
+ const singleLine = allItems.join(' ');
1143
+ console.log(singleLine + colors.reset);
1144
+ }
1145
+
1146
+ // Save cache and return early
1147
+ saveCache(cache);
1148
+ return;
1149
+ }
1150
+
1151
+ // Normal multi-line grouped display with intelligent wrapping
1117
1152
  const lines = [];
1153
+ let currentLine = '';
1154
+ const maxLineLength = settings.display.line_wrap_length || 100;
1118
1155
 
1119
1156
  for (const group of settings.display_order) {
1120
- const lineItems = [];
1121
-
1122
1157
  for (const key of group) {
1123
1158
  if (infoFunctions[key]) {
1124
1159
  try {
1125
1160
  const info = await infoFunctions[key].call(context, settings);
1126
1161
  if (info && info.trim()) {
1127
- lineItems.push(info);
1162
+ // Remove ANSI color codes to get actual text length
1163
+ const infoLength = info.replace(/\x1b\[[0-9;]*m/g, '').length;
1164
+ const currentLineLength = currentLine.replace(/\x1b\[[0-9;]*m/g, '').length;
1165
+
1166
+ // If adding this item would exceed the line length, start a new line
1167
+ if (currentLine && (currentLineLength + infoLength + 1) > maxLineLength) {
1168
+ lines.push(currentLine);
1169
+ currentLine = info;
1170
+ } else {
1171
+ // Add to current line
1172
+ if (currentLine) {
1173
+ currentLine += ' ' + info;
1174
+ } else {
1175
+ currentLine = info;
1176
+ }
1177
+ }
1128
1178
  }
1129
1179
  } catch (error) {
1130
1180
  if (settings.advanced.debug) {
1131
1181
  console.error(`Error getting ${key}:`, error.message);
1132
1182
  }
1133
- // Continue on errors unless debug mode
1134
1183
  }
1135
1184
  } else if (settings.advanced.debug) {
1136
1185
  console.error(`Unknown info function: ${key}`);
1137
1186
  }
1138
1187
  }
1139
-
1140
- // Only add the line if it has content
1141
- if (lineItems.length > 0) {
1142
- lines.push(lineItems.join(' '));
1143
- }
1188
+ }
1189
+
1190
+ // Add the last line if it has content
1191
+ if (currentLine) {
1192
+ lines.push(currentLine);
1144
1193
  }
1145
1194
 
1146
1195
  // Show offline message if no network and IP info was requested but failed
@@ -1351,6 +1400,22 @@ async function main() {
1351
1400
  return;
1352
1401
  }
1353
1402
 
1403
+ // Check for --single-line argument
1404
+ if (args.includes('--single-line')) {
1405
+ const settings = loadSettings();
1406
+ settings.display.single_line = true;
1407
+ await displaySystemInfo();
1408
+ return;
1409
+ }
1410
+
1411
+ // Check for --multi-line argument
1412
+ if (args.includes('--multi-line')) {
1413
+ const settings = loadSettings();
1414
+ settings.display.single_line = false;
1415
+ await displaySystemInfo();
1416
+ return;
1417
+ }
1418
+
1354
1419
  // Check for --help argument
1355
1420
  if (args.includes('--help') || args.includes('-h')) {
1356
1421
  console.log(`
@@ -1393,13 +1458,18 @@ Available colors:
1393
1458
  (use "multicolor" for ports to get rainbow effect)
1394
1459
 
1395
1460
  Display Format:
1396
- The script organizes information into 4 logical categories:
1397
- - Line 1: Device Info - user, hostname, OS, CPU, GPU, device model, kernel
1398
- - Line 2: Dynamic Stats - disk usage, RAM, top process, uptime, temperature, battery, load average
1399
- - Line 3: Network - IP addresses, location, domain, ISP
1400
- - Line 4: System Apps - shell, package managers, open ports, containers, running services
1461
+ Default: Single-line output with all information on one continuous line
1462
+ 👤 user 🏠 hostname OS 📈 CPU 🎮 GPU 💻 device 🔧 kernel 📁 90% 💾 2GB ...
1463
+
1464
+ Multi-line Mode: Use --multi-line or --set display.single_line false
1465
+ Intelligent line wrapping breaks lines at ~100 characters (configurable):
1466
+ - Respects word boundaries and doesn't break in the middle of items
1467
+ - Dynamically arranges items based on actual character length
1468
+ - Ignores ANSI color codes when calculating line length
1469
+
1470
+ Configure line wrap length: --set display.line_wrap_length 80
1401
1471
 
1402
- To customize grouping, modify display_order as an array of arrays:
1472
+ To customize item order, modify display_order as an array of arrays:
1403
1473
  --set display_order '[["user","hostname","os"],["disk_used","ram_used"],["ip","city"],["shell","pacman"]]'
1404
1474
 
1405
1475
  Linux-specific features:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "about-system",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
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": {