mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added a new way to obtain the WiFi network SSID (thanks to @fjh658)
This commit is contained in:
@@ -332,6 +332,10 @@ internal class UsageReader: Reader<Network_Usage>, CWEventDelegate {
|
||||
|
||||
guard self.usage.interface != nil else { return }
|
||||
|
||||
if self.usage.wifiDetails.ssid != nil && (self.usage.wifiDetails.ssid == "" || self.usage.wifiDetails.ssid == "<redacted>") {
|
||||
self.usage.wifiDetails.ssid = nil
|
||||
}
|
||||
|
||||
if self.usage.connectionType == .wifi && self.usage.wifiDetails.ssid == nil || self.usage.wifiDetails.ssid == "" {
|
||||
self.getWiFiDetails()
|
||||
}
|
||||
@@ -341,6 +345,11 @@ internal class UsageReader: Reader<Network_Usage>, CWEventDelegate {
|
||||
if let interface = CWWiFiClient.shared().interface(withName: self.interfaceID) {
|
||||
if let ssid = interface.ssid() {
|
||||
self.usage.wifiDetails.ssid = ssid
|
||||
} else if let cfg = interface.configuration(),
|
||||
let set = (cfg.value(forKey: "networkProfiles") as? NSOrderedSet),
|
||||
let first = set.firstObject as? CWNetworkProfile,
|
||||
let raw = first.ssid, !raw.isEmpty {
|
||||
self.usage.wifiDetails.ssid = raw.replacingOccurrences(of: "’", with: "'").replacingOccurrences(of: "‘", with: "'").trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
if let bssid = interface.bssid() {
|
||||
self.usage.wifiDetails.bssid = bssid
|
||||
|
||||
Reference in New Issue
Block a user