feat: added an option to show ICMP status and latency in the text widget (allows to show ping latency in the menu bar)

This commit is contained in:
Serhiy Mytrovtsiy
2025-03-14 21:17:23 +01:00
parent 24bca54fd3
commit 5effa6440a
3 changed files with 15 additions and 1 deletions

View File

@@ -294,6 +294,13 @@ public class Network: Module {
}
case "$type":
replacement = value.connectionType?.rawValue ?? "-"
case "$icmp":
guard let connectivity = self.connectivityReader?.value else { return }
switch pair.value {
case "status": replacement = localizedString(connectivity.status ? "UP" : "DOWN")
case "latency": replacement = "\(Int(connectivity.latency)) ms"
default: return
}
default: return
}

View File

@@ -48,6 +48,8 @@ You can use a combination of any of the variables. There is only one limitation:
<li><b>$download.total</b>: <small>Total amount of data downloaded over the connection.</small></li>
<li><b>$download</b>: <small>Current download bandwidth used.</small></li>
<li><b>$type</b>: <small>Type of network connection (e.g., Ethernet, Wi-Fi, Cellular).</small></li>
<li><b>$icmp.status</b>: <small>ICMP status.</small></li>
<li><b>$icmp.latency</b>: <small>ICMP latency.</small></li>
</ul>
"""