Waybar/include/modules/network.hpp

43 lines
1.0 KiB
C++
Raw Normal View History

2018-08-09 14:38:24 +00:00
#pragma once
#include <net/if.h>
#include <netlink/netlink.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/ctrl.h>
#include <linux/nl80211.h>
#include <fmt/format.h>
#include "util/chrono.hpp"
#include "ALabel.hpp"
2018-08-09 14:38:24 +00:00
namespace waybar::modules {
class Network : public ALabel {
2018-08-16 12:29:41 +00:00
public:
Network(Json::Value);
auto update() -> void;
private:
2018-08-17 12:24:00 +00:00
static uint64_t netlinkRequest(int, void*, uint32_t, uint32_t groups = 0);
static uint64_t netlinkResponse(int, void*, uint32_t, uint32_t groups = 0);
2018-08-16 12:29:41 +00:00
static int scanCb(struct nl_msg*, void*);
2018-08-17 12:24:00 +00:00
void disconnected();
int getExternalInterface();
2018-08-16 12:29:41 +00:00
void parseEssid(struct nlattr**);
void parseSignal(struct nlattr**);
bool associatedOrJoined(struct nlattr**);
auto getInfo() -> void;
waybar::util::SleeperThread thread_;
2018-08-17 12:24:00 +00:00
int ifid_;
sa_family_t family_;
int sock_fd_;
struct sockaddr_nl nladdr_ = {0};
2018-08-16 12:29:41 +00:00
std::string essid_;
2018-08-17 12:24:00 +00:00
std::string ifname_;
2018-08-16 12:29:41 +00:00
int signal_strength_dbm_;
uint16_t signal_strength_;
};
2018-08-09 14:38:24 +00:00
}