Skip to content

Commit

Permalink
feat: cleaned up Speed widget by refactoring download/upload to input…
Browse files Browse the repository at this point in the history
…/output to make better logic for both modules: Disk and Network which have different meanings for these values.
  • Loading branch information
exelban committed Oct 26, 2024
1 parent 68c45ab commit 905ce8f
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 134 deletions.
254 changes: 130 additions & 124 deletions Kit/Widgets/Speed.swift

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Kit/types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ internal enum StackMode: String {
}

internal let SensorsWidgetValue: [KeyValue_t] = [
KeyValue_t(key: "io", value: "Input/Output"),
KeyValue_t(key: "oi", value: "Output/Input"),
KeyValue_t(key: "oi", value: "output/input"),
KeyValue_t(key: "io", value: "input/output"),
KeyValue_t(key: "separator", value: "separator"),
KeyValue_t(key: "i", value: "Input"),
KeyValue_t(key: "o", value: "Output")
KeyValue_t(key: "i", value: "input"),
KeyValue_t(key: "o", value: "output")
]

internal let SensorsWidgetMode: [KeyValue_t] = [
Expand Down
13 changes: 11 additions & 2 deletions Modules/Disk/config.plist
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,19 @@
<key>Icon</key>
<string>chars</string>
<key>Symbols</key>
<array>
<dict>
<key>Output</key>
<string>W</string>
<key>Input</key>
<string>R</string>
</array>
</dict>
<key>Words</key>
<dict>
<key>Output</key>
<string>Write</string>
<key>Input</key>
<string>Read</string>
</dict>
<key>Order</key>
<integer>5</integer>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Modules/Disk/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public class Disk: Module {
self.menuBar.widgets.filter{ $0.isActive }.forEach { (w: SWidget) in
switch w.item {
case let widget as SpeedWidget:
widget.setValue(upload: d.activity.write, download: d.activity.read)
widget.setValue(input: d.activity.read, output: d.activity.write)
case let widget as NetworkChart:
widget.setValue(upload: Double(d.activity.write), download: Double(d.activity.read))
if self.capacityReader?.interval != 1 {
Expand Down
13 changes: 11 additions & 2 deletions Modules/Net/config.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@
<key>Default</key>
<true/>
<key>Symbols</key>
<array>
<dict>
<key>Output</key>
<string>U</string>
<key>Input</key>
<string>D</string>
</array>
</dict>
<key>Words</key>
<dict>
<key>Output</key>
<string>Upload</string>
<key>Input</key>
<string>Download</string>
</dict>
<key>Order</key>
<integer>1</integer>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Modules/Net/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public class Network: Module {

self.menuBar.widgets.filter{ $0.isActive }.forEach { (w: SWidget) in
switch w.item {
case let widget as SpeedWidget: widget.setValue(upload: upload, download: download)
case let widget as SpeedWidget: widget.setValue(input: download, output: upload)
case let widget as NetworkChart: widget.setValue(upload: Double(upload), download: Double(download))
case let widget as TextWidget:
var text = self.textValue
Expand Down

0 comments on commit 905ce8f

Please sign in to comment.