mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added an Based on cluster colorize option. It will colorize efficiency and performance cores in the bar chart chart widget.
This commit is contained in:
@@ -171,8 +171,9 @@ public class BarChart: WidgetWrapper {
|
||||
if partitionValue.color == nil {
|
||||
switch self.colorState {
|
||||
case .systemAccent: controlAccentColor.set()
|
||||
case .utilization: partitionValue.value.usageColor(zones: self.colorZones, reversed: self.title == "Battery").setFill()
|
||||
case .pressure: self.pressureLevel.pressureColor().setFill()
|
||||
case .utilization: partitionValue.value.usageColor(zones: self.colorZones, reversed: self.title == "Battery").set()
|
||||
case .pressure: self.pressureLevel.pressureColor().set()
|
||||
case .cluster: (partitionValue.value.clusterColor(i) ?? controlAccentColor).set()
|
||||
case .monochrome:
|
||||
if self.boxState {
|
||||
(isDarkMode ? NSColor.black : NSColor.white).set()
|
||||
|
||||
@@ -193,6 +193,22 @@ public extension Double {
|
||||
}
|
||||
}
|
||||
|
||||
func clusterColor(_ i: Int) -> NSColor? {
|
||||
guard let cores = SystemKit.shared.device.info.cpu?.cores,
|
||||
let core = cores.first(where: {$0.id == i }) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch core.type {
|
||||
case .efficiency:
|
||||
return .systemTeal
|
||||
case .performance:
|
||||
return .systemBlue
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func secondsToHoursMinutesSeconds() -> (Int, Int) {
|
||||
let mins = (self.truncatingRemainder(dividingBy: 3600)) / 60
|
||||
return (Int(self / 3600), Int(mins))
|
||||
|
||||
@@ -120,6 +120,7 @@ public struct Color: KeyValue_p, Equatable {
|
||||
extension Color: CaseIterable {
|
||||
public static var utilization: Color { return Color(key: "utilization", value: "Based on utilization", additional: NSColor.black) }
|
||||
public static var pressure: Color { return Color(key: "pressure", value: "Based on pressure", additional: NSColor.black) }
|
||||
public static var cluster: Color { return Color(key: "cluster", value: "Based on cluster", additional: NSColor.black) }
|
||||
|
||||
public static var separator1: Color { return Color(key: "separator_1", value: "separator_1", additional: NSColor.black) }
|
||||
|
||||
@@ -160,7 +161,7 @@ extension Color: CaseIterable {
|
||||
} }
|
||||
|
||||
public static var allCases: [Color] {
|
||||
return [.utilization, .pressure, separator1,
|
||||
return [.utilization, .pressure, .cluster, separator1,
|
||||
.systemAccent, .monochrome, separator2,
|
||||
.clear, .white, .black, .gray, .secondGray, .darkGray, .lightGray,
|
||||
.red, .secondRed, .green, .secondGreen, .blue, .secondBlue, .yellow, .secondYellow,
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<key>Unsupported colors</key>
|
||||
<array>
|
||||
<string>pressure</string>
|
||||
<string>cluster</string>
|
||||
</array>
|
||||
<key>Order</key>
|
||||
<integer>2</integer>
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<key>Unsupported colors</key>
|
||||
<array>
|
||||
<string>pressure</string>
|
||||
<string>cluster</string>
|
||||
</array>
|
||||
<key>Order</key>
|
||||
<integer>2</integer>
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<key>Unsupported colors</key>
|
||||
<array>
|
||||
<string>pressure</string>
|
||||
<string>cluster</string>
|
||||
</array>
|
||||
<key>Order</key>
|
||||
<integer>3</integer>
|
||||
|
||||
@@ -59,6 +59,10 @@
|
||||
</dict>
|
||||
<key>Order</key>
|
||||
<integer>3</integer>
|
||||
<key>Unsupported colors</key>
|
||||
<array>
|
||||
<string>cluster</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>pie_chart</key>
|
||||
<dict>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<key>Unsupported colors</key>
|
||||
<array>
|
||||
<string>pressure</string>
|
||||
<string>cluster</string>
|
||||
</array>
|
||||
<key>Order</key>
|
||||
<integer>2</integer>
|
||||
|
||||
Reference in New Issue
Block a user