1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 04:06:03 +00:00
* Work for #17 : Now we have ssid

* Since we are using Objective-C++ NSStrings, we need to link to Foundation.framework, too!

* If interface is UP use the interface SSID; otherwise "off/any" following the Linux implementation.
Add more

* More

* cleanup
This commit is contained in:
lasers 2018-10-11 07:45:43 -05:00 committed by Brenden Matthews
parent 30c19a14f5
commit 1e2a29654f
2 changed files with 61 additions and 1 deletions

View File

@ -139,7 +139,9 @@ endif(BUILD_NCURSES AND OS_DARWIN)
if(BUILD_WLAN AND OS_DARWIN)
find_library(CW CoreWLAN)
find_library(NS Foundation)
set(conky_libs ${conky_libs} ${CW})
set(conky_libs ${conky_libs} ${NS})
endif(BUILD_WLAN AND OS_DARWIN)
if(OS_DARWIN AND BUILD_IPGFREQ)

View File

@ -652,10 +652,68 @@ int update_meminfo() {
#ifdef BUILD_WLAN
void update_wlan_stats(struct net_stat *ns) {
CWWiFiClient *client = [CWWiFiClient sharedWiFiClient];
CWInterface *interface = [client interfaceWithName:[NSString stringWithUTF8String:ns->dev]];
if (!interface)
return;
const char *essid = (ns->up) ? [interface ssid].UTF8String : "off/any";
const char *freq = "Unknown";
const char *bitrate = [NSString stringWithFormat:@"%f", [interface transmitRate]].UTF8String;
const char *mode = "Unknown";
const char *ap = [interface hardwareAddress].UTF8String;
if (essid == nullptr || bitrate == nullptr || ap == nullptr)
return;
/*
* Freq
*/
switch ([interface wlanChannel].channelBand) {
case kCWChannelBand2GHz:
freq = "2 GHz";
break;
case kCWChannelBand5GHz:
freq = "5 GHz";
break;
case kCWChannelBandUnknown:
default:
break;
}
/*
* Mode
*/
switch ([interface interfaceMode]) {
case kCWInterfaceModeStation:
mode = "Managed";
break;
case kCWInterfaceModeIBSS:
mode = "Ad-Hoc";
break;
case kCWInterfaceModeHostAP:
mode = "Master";
break;
case kCWInterfaceModeNone:
default:
break;
}
/*
* Setup
*/
memcpy(ns->essid, essid, sizeof(char)*strlen(essid));
ns->channel = interface.wlanChannel.channelNumber;
memcpy(ns->freq, freq, sizeof(char)*strlen(freq));
memcpy(ns->bitrate, bitrate, sizeof(char)*strlen(bitrate));
memcpy(ns->mode, mode, sizeof(char)*strlen(mode));
ns->link_qual = 0;
ns->link_qual_max = 0;
memcpy(ns->ap, ap, sizeof(char)*strlen(ap));
}
#endif
#endif /* BUILD_WLAN */
int update_net_stats() {
struct net_stat *ns;