feat: Add wifi network link bitrate value
In order to obtain the RX and TX bitrates from the kernel netlink we need to open a second info socket to get the station data. The values are formatted like "1.9Gb/s" and then exposed as `rx_bitrate` and `tx_bitrate`. This code is closely following the `iw` implementation.
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include "util/rfkill.hpp"
|
||||
#endif
|
||||
|
||||
#define ETH_ALEN 6
|
||||
|
||||
enum ip_addr_pref : uint8_t { IPV4, IPV6, IPV4_6 };
|
||||
|
||||
namespace waybar::modules {
|
||||
@@ -34,6 +36,7 @@ class Network : public ALabel {
|
||||
static int handleEvents(struct nl_msg*, void*);
|
||||
static int handleEventsDone(struct nl_msg*, void*);
|
||||
static int handleScan(struct nl_msg*, void*);
|
||||
static int handleStationGet(struct nl_msg *msg, void *data);
|
||||
|
||||
void askForStateDump(void);
|
||||
|
||||
@@ -57,6 +60,7 @@ class Network : public ALabel {
|
||||
struct sockaddr_nl nladdr_{0};
|
||||
struct nl_sock* sock_{nullptr};
|
||||
struct nl_sock* ev_sock_{nullptr};
|
||||
struct nl_sock* station_sock_{nullptr};
|
||||
int efd_{-1};
|
||||
int ev_fd_{-1};
|
||||
int nl80211_id_{-1};
|
||||
@@ -95,6 +99,8 @@ class Network : public ALabel {
|
||||
util::Rfkill rfkill_{RFKILL_TYPE_WLAN};
|
||||
#endif
|
||||
float frequency_{0};
|
||||
uint32_t tx_bitrate_{0};
|
||||
uint32_t rx_bitrate_{0};
|
||||
};
|
||||
|
||||
} // namespace waybar::modules
|
||||
|
||||
Reference in New Issue
Block a user