Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5effa64

Browse files
committed
feat: added an option to show ICMP status and latency in the text widget (allows to show ping latency in the menu bar)
1 parent24bca54 commit5effa64

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

‎Kit/module/reader.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ open class Reader<T: Codable>: NSObject, ReaderInternal_p {
4141
publicvarlog:NextLog{
4242
NextLog.shared.copy(category:"\(String(describing:self))")
4343
}
44-
publicvarvalue:T?
44+
privateletvalueQueue=DispatchQueue(label:"eu.exelban.readerActiveQueue")
45+
privatevar_value:T?
46+
publicvarvalue:T?{
47+
get{self.valueQueue.sync{self._value}}
48+
set{self.valueQueue.sync{self._value= newValue}}
49+
}
4550
publicvarname:String{
4651
String(NSStringFromClass(type(of:self)).split(separator:".").last??"unknown")
4752
}

‎Modules/Net/main.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ public class Network: Module {
294294
}
295295
case"$type":
296296
replacement= value.connectionType?.rawValue??"-"
297+
case"$icmp":
298+
guardlet connectivity=self.connectivityReader?.valueelse{return}
299+
switch pair.value{
300+
case"status": replacement=localizedString(connectivity.status?"UP":"DOWN")
301+
case"latency": replacement="\(Int(connectivity.latency)) ms"
302+
default:return
303+
}
297304
default:return
298305
}
299306

‎Modules/Net/settings.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ You can use a combination of any of the variables. There is only one limitation:
4848
<li><b>$download.total</b>: <small>Total amount of data downloaded over the connection.</small></li>
4949
<li><b>$download</b>: <small>Current download bandwidth used.</small></li>
5050
<li><b>$type</b>: <small>Type of network connection (e.g., Ethernet, Wi-Fi, Cellular).</small></li>
51+
<li><b>$icmp.status</b>: <small>ICMP status.</small></li>
52+
<li><b>$icmp.latency</b>: <small>ICMP latency.</small></li>
5153
</ul>
5254
"""
5355

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp