2016-05-31 05:58:58 +02:00
|
|
|
#pragma once
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
#include "adapters/net.hpp"
|
2016-10-18 09:34:35 +02:00
|
|
|
#include "components/config.hpp"
|
2016-11-20 23:04:31 +01:00
|
|
|
#include "modules/meta/timer_module.hpp"
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS
|
2016-06-15 05:32:35 +02:00
|
|
|
|
|
|
|
namespace modules {
|
2016-10-18 09:34:35 +02:00
|
|
|
enum class connection_state { NONE = 0, CONNECTED, DISCONNECTED, PACKETLOSS };
|
2016-06-15 05:32:35 +02:00
|
|
|
|
|
|
|
class network_module : public timer_module<network_module> {
|
|
|
|
public:
|
2016-12-21 08:00:09 +01:00
|
|
|
explicit network_module(const bar_settings&, string);
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-02 20:22:45 +01:00
|
|
|
void teardown();
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
2016-11-25 13:55:15 +01:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2020-05-15 19:59:08 +02:00
|
|
|
static constexpr auto TYPE = "internal/network";
|
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
protected:
|
2016-11-02 20:22:45 +01:00
|
|
|
void subthread_routine();
|
2016-06-15 05:32:35 +02:00
|
|
|
|
|
|
|
private:
|
2016-05-26 02:14:56 +02:00
|
|
|
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>";
|
2016-10-18 09:34:35 +02:00
|
|
|
static constexpr auto TAG_RAMP_QUALITY = "<ramp-quality>";
|
2016-05-26 02:14:56 +02:00
|
|
|
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 16:41:06 +02:00
|
|
|
|
2016-10-18 09:34:35 +02:00
|
|
|
net::wired_t m_wired;
|
|
|
|
net::wireless_t m_wireless;
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-06-15 05:32:35 +02:00
|
|
|
ramp_t m_ramp_signal;
|
2016-10-18 09:34:35 +02:00
|
|
|
ramp_t m_ramp_quality;
|
2016-06-15 05:32:35 +02:00
|
|
|
animation_t m_animation_packetloss;
|
2016-10-18 09:34:35 +02:00
|
|
|
map<connection_state, label_t> m_label;
|
2016-05-31 11:49:33 +02:00
|
|
|
|
2016-12-23 05:18:58 +01:00
|
|
|
atomic<bool> m_connected{false};
|
|
|
|
atomic<bool> m_packetloss{false};
|
2016-05-19 16:41:06 +02:00
|
|
|
|
2016-11-22 20:53:14 +01:00
|
|
|
int m_signal{0};
|
|
|
|
int m_quality{0};
|
|
|
|
int m_counter{-1}; // -1 to ignore the first run
|
2016-10-18 09:34:35 +02:00
|
|
|
|
|
|
|
string m_interface;
|
2016-11-22 20:53:14 +01:00
|
|
|
int m_ping_nth_update{0};
|
|
|
|
int m_udspeed_minwidth{0};
|
|
|
|
bool m_accumulate{false};
|
2017-11-02 23:05:26 -07:00
|
|
|
bool m_unknown_up{false};
|
2020-11-29 14:15:27 +01:00
|
|
|
string m_udspeed_unit{"B/s"};
|
2016-05-19 16:41:06 +02:00
|
|
|
};
|
2020-05-15 19:59:08 +02:00
|
|
|
} // namespace modules
|
2016-06-15 05:32:35 +02:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS_END
|