feat: 添加对Darwin和FreeBSD的GPU及操作系统名称获取功能

This commit is contained in:
Akizon77
2025-06-29 20:24:05 +08:00
parent 8cd60d448a
commit e1f52b9b77
9 changed files with 230 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
//go:build darwin
// +build darwin
package monitoring
import (
"os/exec"
"strings"
)
// GpuName returns the name of the GPU on Darwin (macOS)
func GpuName() string {
cmd := exec.Command("system_profiler", "SPDisplaysDataType")
output, err := cmd.Output()
if err != nil {
return "Unknown"
}
lines := strings.Split(string(output), "\n")
for _, line := range lines {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "Chipset Model:") {
return strings.TrimSpace(strings.TrimPrefix(line, "Chipset Model:"))
}
}
return "Unknown"
}