fix: fixed multi gpu in the Dashboard (SystemKit)

This commit is contained in:
Serhiy Mytrovtsiy
2021-04-01 19:18:45 +02:00
parent 487619b82f
commit d3ea2fd030
2 changed files with 11 additions and 4 deletions

View File

@@ -266,7 +266,7 @@ class Dashboard: NSScrollView {
var row = gpus[i].name != nil ? gpus[i].name! : LocalizedString("Unknown")
if let size = gpus[i].vram {
row += " \(size)"
row += " (\(size))"
}
value += "\(row)\(i == gpus.count-1 ? "" : "\n")"

View File

@@ -223,13 +223,20 @@ public class SystemKit {
do {
if let json = try JSONSerialization.jsonObject(with: Data(res.utf8), options: []) as? [String: Any] {
if let arr = json["SPDisplaysDataType"] as? [[String:Any]] {
var gpu: gpu_s = gpu_s()
for obj in arr {
var gpu: gpu_s = gpu_s()
gpu.name = obj["sppci_model"] as? String
gpu.vendor = obj["spdisplays_vendor"] as? String
gpu.vram = obj["spdisplays_vram_shared"] as? String
if let vram = obj["spdisplays_vram_shared"] as? String {
gpu.vram = vram
} else if let vram = obj["spdisplays_vram"] as? String {
gpu.vram = vram
}
list.append(gpu)
}
list.append(gpu)
}
}
} catch let error as NSError {