From d3ea2fd030d86b75ce292f5c2c7f64a58d1db65b Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Thu, 1 Apr 2021 19:18:45 +0200 Subject: [PATCH] fix: fixed multi gpu in the Dashboard (SystemKit) --- Stats/Views/Dashboard.swift | 2 +- StatsKit/SystemKit.swift | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Stats/Views/Dashboard.swift b/Stats/Views/Dashboard.swift index aa9a6498..9f675cbc 100644 --- a/Stats/Views/Dashboard.swift +++ b/Stats/Views/Dashboard.swift @@ -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")" diff --git a/StatsKit/SystemKit.swift b/StatsKit/SystemKit.swift index 458d9a2a..3c7125aa 100644 --- a/StatsKit/SystemKit.swift +++ b/StatsKit/SystemKit.swift @@ -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 {