about-system 0.0.9 → 0.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/about-system.js +32 -69
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "about-system",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
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": "src/about-system.js",
6
6
  "bin": {
@@ -574,38 +574,38 @@ const infoFunctions = {
574
574
  if (cached) return cached;
575
575
 
576
576
  if (IS_WINDOWS) {
577
- try {
578
- // Get disk usage for C: drive using PowerShell
579
- const ps = execCommand('powershell.exe -Command "Get-WmiObject -Class Win32_LogicalDisk -Filter \'DeviceID="C:"\' | Select-Object @{Name=\'PercentFree\';Expression={[math]::Round((($_.FreeSpace / $_.Size) * 100), 0)}} | Select-Object -ExpandProperty PercentFree"');
580
- if (ps.trim()) {
581
- const percentFree = parseInt(ps.trim());
582
- const percentUsed = 100 - percentFree;
583
- const color = colors[settings.colors.disk_used] || colors.purple;
584
- const emoji = settings.display.show_emojis ? '📁 ' : '';
585
- const result = `${color}${emoji}${percentUsed}%`;
586
- setCachedValue(this.cache, 'disk_used', result);
587
- return result;
588
- }
589
- } catch {}
577
+ // try {
578
+ // // Get disk usage for C: drive using PowerShell
579
+ // const ps = execCommand('powershell.exe -Command "Get-WmiObject -Class Win32_LogicalDisk -Filter \'DeviceID="C:"\' | Select-Object @{Name=\'PercentFree\';Expression={[math]::Round((($_.FreeSpace / $_.Size) * 100), 0)}} | Select-Object -ExpandProperty PercentFree"');
580
+ // if (ps.trim()) {
581
+ // const percentFree = parseInt(ps.trim());
582
+ // const percentUsed = 100 - percentFree;
583
+ // const color = colors[settings.colors.disk_used] || colors.purple;
584
+ // const emoji = settings.display.show_emojis ? '📁 ' : '';
585
+ // const result = `${color}${emoji}${percentUsed}%`;
586
+ // setCachedValue(this.cache, 'disk_used', result);
587
+ // return result;
588
+ // }
589
+ // } catch {}
590
590
 
591
- // Fallback using WMIC
592
- try {
593
- const wmic = execCommand('wmic logicaldisk where "DeviceID=\'C:\'" get Size,FreeSpace /format:list');
594
- const sizeMatch = wmic.match(/Size=(\d+)/);
595
- const freeMatch = wmic.match(/FreeSpace=(\d+)/);
591
+ // // Fallback using WMIC
592
+ // try {
593
+ // const wmic = execCommand('wmic logicaldisk where "DeviceID=\'C:\'" get Size,FreeSpace /format:list');
594
+ // const sizeMatch = wmic.match(/Size=(\d+)/);
595
+ // const freeMatch = wmic.match(/FreeSpace=(\d+)/);
596
596
 
597
- if (sizeMatch && freeMatch) {
598
- const size = parseInt(sizeMatch[1]);
599
- const free = parseInt(freeMatch[1]);
600
- const used = size - free;
601
- const percentUsed = Math.round((used / size) * 100);
602
- const color = colors[settings.colors.disk_used] || colors.purple;
603
- const emoji = settings.display.show_emojis ? '📁 ' : '';
604
- const result = `${color}${emoji}${percentUsed}%`;
605
- setCachedValue(this.cache, 'disk_used', result);
606
- return result;
607
- }
608
- } catch {}
597
+ // if (sizeMatch && freeMatch) {
598
+ // const size = parseInt(sizeMatch[1]);
599
+ // const free = parseInt(freeMatch[1]);
600
+ // const used = size - free;
601
+ // const percentUsed = Math.round((used / size) * 100);
602
+ // const color = colors[settings.colors.disk_used] || colors.purple;
603
+ // const emoji = settings.display.show_emojis ? '📁 ' : '';
604
+ // const result = `${color}${emoji}${percentUsed}%`;
605
+ // setCachedValue(this.cache, 'disk_used', result);
606
+ // return result;
607
+ // }
608
+ // } catch {}
609
609
  } else if (IS_LINUX) {
610
610
  try {
611
611
  const df = execCommand('df -h');
@@ -697,45 +697,8 @@ const infoFunctions = {
697
697
  top_process(settings) {
698
698
  const cached = getCachedValue(this.cache, 'top_process', settings);
699
699
  if (cached) return cached;
700
-
701
- if (IS_WINDOWS) {
702
- try {
703
- // Get top process using PowerShell performance counters
704
- const ps = execCommand('powershell.exe -Command "Get-Counter \'\\Process(*)\\% Processor Time\' | Select-Object -ExpandProperty CounterSamples | Where-Object {$_.InstanceName -notin @(\'_Total\', \'Idle\')} | Sort-Object CookedValue -Descending | Select-Object -First 1 | Select-Object InstanceName, @{Name=\'CPU%\'; Expression={[math]::Round($_.CookedValue, 1)}}"');
705
- const lines = ps.split('\n').filter(line => line.trim());
706
- if (lines.length > 0) {
707
- const parts = lines[0].trim().split(/\s+/);
708
- if (parts.length >= 2) {
709
- const processName = parts[0];
710
- const cpuPercent = parts[1];
711
- const color = colors[settings.colors.top_process] || colors.magenta;
712
- const emoji = settings.display.show_emojis ? '🔝 ' : '';
713
- const result = `${color}${emoji}${cpuPercent}% ${processName}`;
714
- setCachedValue(this.cache, 'top_process', result);
715
- return result;
716
- }
717
- }
718
- } catch {}
719
-
720
- // Fallback using tasklist
721
- try {
722
- const tasklist = execCommand('tasklist /fo csv | findstr /v "Image Name" | sort /r /+5');
723
- const lines = tasklist.split('\n').filter(line => line.trim());
724
- if (lines.length > 0) {
725
- const line = lines[0];
726
- const parts = line.split(',');
727
- if (parts.length >= 5) {
728
- const processName = parts[0].replace(/"/g, '').split('.')[0];
729
- const memoryUsage = parts[4].replace(/"/g, '').replace(/[,\s]/g, '');
730
- const color = colors[settings.colors.top_process] || colors.magenta;
731
- const emoji = settings.display.show_emojis ? '🔝 ' : '';
732
- const result = `${color}${emoji}${memoryUsage}KB ${processName}`;
733
- setCachedValue(this.cache, 'top_process', result);
734
- return result;
735
- }
736
- }
737
- } catch {}
738
- } else if (IS_LINUX) {
700
+
701
+ if (IS_LINUX) {
739
702
  try {
740
703
  const ps = execCommand('ps -eo pcpu,comm --sort=-%cpu --no-headers');
741
704
  const lines = ps.split('\n');