1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/modules/network.hpp

58 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
#include "adapters/net.hpp"
#include "components/config.hpp"
2016-11-20 17:04:31 -05:00
#include "modules/meta/timer_module.hpp"
2016-06-14 23:32:35 -04:00
2016-11-19 00:22:44 -05:00
POLYBAR_NS
2016-06-14 23:32:35 -04:00
namespace modules {
enum class connection_state { NONE = 0, CONNECTED, DISCONNECTED, PACKETLOSS };
2016-06-14 23:32:35 -04:00
class network_module : public timer_module<network_module> {
public:
explicit network_module(const bar_settings&, string);
2016-06-14 23:32:35 -04:00
2016-11-02 15:22:45 -04:00
void teardown();
bool update();
string get_format() const;
2016-11-25 07:55:15 -05:00
bool build(builder* builder, const string& tag) const;
2016-06-14 23:32:35 -04:00
protected:
2016-11-02 15:22:45 -04:00
void subthread_routine();
2016-06-14 23:32:35 -04:00
private:
static constexpr auto FORMAT_CONNECTED = "format-connected";
static constexpr auto FORMAT_PACKETLOSS = "format-packetloss";
static constexpr auto FORMAT_DISCONNECTED = "format-disconnected";
static constexpr auto TAG_RAMP_SIGNAL = "<ramp-signal>";
static constexpr auto TAG_RAMP_QUALITY = "<ramp-quality>";
static constexpr auto TAG_LABEL_CONNECTED = "<label-connected>";
static constexpr auto TAG_LABEL_DISCONNECTED = "<label-disconnected>";
static constexpr auto TAG_LABEL_PACKETLOSS = "<label-packetloss>";
static constexpr auto TAG_ANIMATION_PACKETLOSS = "<animation-packetloss>";
2016-05-19 10:41:06 -04:00
net::wired_t m_wired;
net::wireless_t m_wireless;
2016-05-19 10:41:06 -04:00
2016-06-14 23:32:35 -04:00
ramp_t m_ramp_signal;
ramp_t m_ramp_quality;
2016-06-14 23:32:35 -04:00
animation_t m_animation_packetloss;
map<connection_state, label_t> m_label;
2016-12-22 23:18:58 -05:00
atomic<bool> m_connected{false};
atomic<bool> m_packetloss{false};
2016-05-19 10:41:06 -04:00
int m_signal{0};
int m_quality{0};
int m_counter{-1}; // -1 to ignore the first run
string m_interface;
int m_ping_nth_update{0};
int m_udspeed_minwidth{0};
bool m_accumulate{false};
2016-05-19 10:41:06 -04:00
};
}
2016-06-14 23:32:35 -04:00
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END