Skip to content

Commit

Permalink
fix: fixed CPU widget update for intel based Macs (#2024)
Browse files Browse the repository at this point in the history
  • Loading branch information
exelban committed Jul 8, 2024
1 parent 0caf141 commit 1d4b411
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions Modules/CPU/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ public class CPU: Module {
self.portalView.callback(value)
self.notificationsView.loadCallback(value)

if #available(macOS 11.0, *) {
guard let blobData = try? JSONEncoder().encode(value) else { return }
self.userDefaults?.set(blobData, forKey: "CPU@LoadReader")
WidgetCenter.shared.reloadTimelines(ofKind: CPU_entry.kind)
}

self.menuBar.widgets.filter{ $0.isActive }.forEach { (w: SWidget) in
switch w.item {
case let widget as Mini: widget.setValue(value.totalUsage)
Expand Down Expand Up @@ -213,5 +207,11 @@ public class CPU: Module {
default: break
}
}

if #available(macOS 11.0, *) {
guard let blobData = try? JSONEncoder().encode(value) else { return }
self.userDefaults?.set(blobData, forKey: "CPU@LoadReader")
WidgetCenter.shared.reloadTimelines(ofKind: CPU_entry.kind)
}
}
}
12 changes: 6 additions & 6 deletions Modules/RAM/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ public class RAM: Module {
self.portalView.callback(value)
self.notificationsView.loadCallback(value)

if #available(macOS 11.0, *) {
guard let blobData = try? JSONEncoder().encode(value) else { return }
self.userDefaults?.set(blobData, forKey: "RAM@UsageReader")
WidgetCenter.shared.reloadTimelines(ofKind: RAM_entry.kind)
}

let total: Double = value.total == 0 ? 1 : value.total
self.menuBar.widgets.filter{ $0.isActive }.forEach { (w: SWidget) in
switch w.item {
Expand Down Expand Up @@ -182,5 +176,11 @@ public class RAM: Module {
default: break
}
}

if #available(macOS 11.0, *) {
guard let blobData = try? JSONEncoder().encode(value) else { return }
self.userDefaults?.set(blobData, forKey: "RAM@UsageReader")
WidgetCenter.shared.reloadTimelines(ofKind: RAM_entry.kind)
}
}
}
4 changes: 2 additions & 2 deletions Stats.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 2.11.0;
MARKETING_VERSION = 2.11.1;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2785,7 +2785,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 2.11.0;
MARKETING_VERSION = 2.11.1;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
2 changes: 1 addition & 1 deletion Stats/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>575</string>
<string>577</string>
<key>Description</key>
<string>Simple macOS system monitor in your menu bar</string>
<key>LSApplicationCategoryType</key>
Expand Down

0 comments on commit 1d4b411

Please sign in to comment.