From 6b3f3029ffedacc03f59a2c7df8be549bed96016 Mon Sep 17 00:00:00 2001 From: Carterpersall Date: Tue, 8 Nov 2022 11:41:46 -0600 Subject: [PATCH 1/4] New Method Working - Replaces the CIM method with one that uses the registry - Uses `[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0")` to get a registry key much faster than `Get-ItemProperty` - Currently doesn't round the frequency as rounding is slow --- winfetch.ps1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/winfetch.ps1 b/winfetch.ps1 index ef3047c..b92df36 100644 --- a/winfetch.ps1 +++ b/winfetch.ps1 @@ -687,16 +687,20 @@ function info_theme { # ===== CPU/GPU ===== function info_cpu { - $cpu = Get-CimInstance -ClassName Win32_Processor -Property Name,MaxClockSpeed -CimSession $cimSession - $cpuname = if ($cpu.Name.Contains('@')) { - ($cpu.Name -Split ' @ ')[0].Trim() + # Get CPU Information + $cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") + $cpuName = $cpu.GetValue("ProcessorNameString") + + # If the CPU name has the frequency in it, remove it + $cpuName = if ($cpuName -Contains '@') { + ($cpuName -Split ' @ ')[0].Trim() } else { - $cpu.Name.Trim() + $cpuName.Trim() } - $cpufreq = [math]::round((([int]$cpu.MaxClockSpeed)/1000), 2) + return @{ title = "CPU" - content = "${cpuname} @ ${cpufreq}GHz" + content = "$cpuName @ $($cpu.GetValue("~MHz") / 1000)GHz" # [math]::Round($cpu.GetValue("~MHz") / 1000, 1) is 2-5ms slower } } From 11d1d763cc3764df572771113840adbb9f4bc700 Mon Sep 17 00:00:00 2001 From: Carterpersall Date: Tue, 8 Nov 2022 12:14:16 -0600 Subject: [PATCH 2/4] Actually supply it with the computer's name --- winfetch.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winfetch.ps1 b/winfetch.ps1 index b92df36..6d2ef84 100644 --- a/winfetch.ps1 +++ b/winfetch.ps1 @@ -688,7 +688,7 @@ function info_theme { # ===== CPU/GPU ===== function info_cpu { # Get CPU Information - $cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computername).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") + $cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") $cpuName = $cpu.GetValue("ProcessorNameString") # If the CPU name has the frequency in it, remove it From 6f411bae2dc838f9b9350701dcd934d68a7d4850 Mon Sep 17 00:00:00 2001 From: Carterpersall Date: Thu, 12 Jan 2023 10:56:36 -0600 Subject: [PATCH 3/4] Maybe Fix Bug and use smallcase Attempt to fix bug with duplication of frequency by removing whitespace in split command --- winfetch.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/winfetch.ps1 b/winfetch.ps1 index 6d2ef84..9c178e4 100644 --- a/winfetch.ps1 +++ b/winfetch.ps1 @@ -689,18 +689,18 @@ function info_theme { function info_cpu { # Get CPU Information $cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") - $cpuName = $cpu.GetValue("ProcessorNameString") + $cpuname = $cpu.GetValue("ProcessorNameString") # If the CPU name has the frequency in it, remove it - $cpuName = if ($cpuName -Contains '@') { - ($cpuName -Split ' @ ')[0].Trim() + $cpuName = if ($cpuname -Contains '@') { + ($cpuname -Split '@')[0].Trim() } else { - $cpuName.Trim() + $cpuname.Trim() } return @{ title = "CPU" - content = "$cpuName @ $($cpu.GetValue("~MHz") / 1000)GHz" # [math]::Round($cpu.GetValue("~MHz") / 1000, 1) is 2-5ms slower + content = "$cpuname @ $($cpu.GetValue("~MHz") / 1000)GHz" # [math]::Round($cpu.GetValue("~MHz") / 1000, 1) is 2-5ms slower } } From 13e0e0671fb3cc90fe3df4821cd8fec2fc84d63c Mon Sep 17 00:00:00 2001 From: Rashil Gandhi Date: Tue, 31 Jan 2023 16:28:21 +0530 Subject: [PATCH 4/4] Update winfetch.ps1 --- winfetch.ps1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/winfetch.ps1 b/winfetch.ps1 index 9c178e4..9af7650 100644 --- a/winfetch.ps1 +++ b/winfetch.ps1 @@ -687,17 +687,13 @@ function info_theme { # ===== CPU/GPU ===== function info_cpu { - # Get CPU Information - $cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $env:COMPUTERNAME).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") + $cpu = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Env:COMPUTERNAME).OpenSubKey("HARDWARE\DESCRIPTION\System\CentralProcessor\0") $cpuname = $cpu.GetValue("ProcessorNameString") - - # If the CPU name has the frequency in it, remove it - $cpuName = if ($cpuname -Contains '@') { + $cpuname = if ($cpuname.Contains('@')) { ($cpuname -Split '@')[0].Trim() } else { $cpuname.Trim() } - return @{ title = "CPU" content = "$cpuname @ $($cpu.GetValue("~MHz") / 1000)GHz" # [math]::Round($cpu.GetValue("~MHz") / 1000, 1) is 2-5ms slower