mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added Bar chart view to the Sensors module (for Fans only!) (#839)
This commit is contained in:
@@ -83,7 +83,7 @@ public enum widget_t: String {
|
||||
case is BarChart:
|
||||
if module == "GPU" || module == "RAM" || module == "Disk" || module == "Battery" {
|
||||
width = 11 + (Constants.Widget.margin.x*2)
|
||||
} else if module == "Fans" {
|
||||
} else if module == "Sensors" {
|
||||
width = 22 + (Constants.Widget.margin.x*2)
|
||||
} else if module == "CPU" {
|
||||
width = 30 + (Constants.Widget.margin.x*2)
|
||||
|
||||
@@ -27,6 +27,24 @@
|
||||
<key>Order</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>bar_chart</key>
|
||||
<dict>
|
||||
<key>Default</key>
|
||||
<false/>
|
||||
<key>Preview</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<string>0.36,0.3</string>
|
||||
<key>Color</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>Unsupported colors</key>
|
||||
<array>
|
||||
<string>pressure</string>
|
||||
</array>
|
||||
<key>Order</key>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -67,9 +67,14 @@ public class Sensors: Module {
|
||||
}
|
||||
|
||||
var list: [KeyValue_t] = []
|
||||
var flatList: [[ColorValue]] = []
|
||||
|
||||
value.forEach { (s: Sensor_p) in
|
||||
if s.state {
|
||||
list.append(KeyValue_t(key: s.key, value: s.formattedMiniValue))
|
||||
if let f = s as? Fan {
|
||||
flatList.append([ColorValue(((f.value*100)/f.maxSpeed)/100)])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +83,7 @@ public class Sensors: Module {
|
||||
self.widgets.filter{ $0.isActive }.forEach { (w: Widget) in
|
||||
switch w.item {
|
||||
case let widget as SensorsWidget: widget.setValues(list)
|
||||
case let widget as BarChart: widget.setValue(flatList)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ internal class FanView: NSStackView {
|
||||
var speed = ""
|
||||
if value.value != 1 {
|
||||
if self.fan.maxSpeed == 1 || self.fan.maxSpeed == 0 {
|
||||
speed = "\(Int(value.value))RPM"
|
||||
speed = "\(Int(value.value)) RPM"
|
||||
} else {
|
||||
speed = "\((100*Int(value.value)) / Int(self.fan.maxSpeed))%"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user