From 428ee7ceeed38a2e2e35928073ae019f6dca0026 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Tue, 23 Dec 2025 11:21:40 +0200 Subject: [PATCH] Improve 'cpus' module --- src/hardware.go | 19 ++++++++++++++++--- src/modules.go | 2 -- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/hardware.go b/src/hardware.go index 9e34100..1e4e6b7 100644 --- a/src/hardware.go +++ b/src/hardware.go @@ -10,7 +10,6 @@ import ( ) type CPU struct { - Vendor string Model string Cores int Threads int @@ -44,9 +43,23 @@ func GetCPUs(hiddenCPUs []int) []CPU { continue } + // Remove unnecessary information from the CPU model + model := cpu.Model + stringsToRemove := []string{ + " CPU", " FPU", " APU", " Processor", + " Dual-Core", " Quad-Core", " Six-Core", " Eight-Core", " Ten-Core", + " 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core", + } + for _, str := range stringsToRemove { + model = strings.ReplaceAll(model, str, "") + } + model = strings.Split(model, "w/ Radeon ")[0] + model = strings.Split(model, "with Radeon ")[0] + model = strings.Split(model, "@")[0] + model = strings.TrimSpace(model) + ret = append(ret, CPU{ - Vendor: cpu.Vendor, - Model: cpu.Model, + Model: model, Cores: int(cpu.NumCores), Threads: int(cpu.NumThreads), }) diff --git a/src/modules.go b/src/modules.go index 7aa39a3..564763d 100644 --- a/src/modules.go +++ b/src/modules.go @@ -200,8 +200,6 @@ func initializeModuleMap() { switch s { case "CPU_NUM": return strconv.Itoa(i + 1) - case "CPU_VENDOR": - return cpu.Vendor case "CPU_MODEL": return cpu.Model case "CPU_CORES":