mirror of https://github.com/polybar/polybar.git
Compare commits
2 Commits
e726770af4
...
64e4395318
Author | SHA1 | Date |
---|---|---|
Joseph Dalrymple | 64e4395318 | |
Joseph Dalrymple | 32834a8ae7 |
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [Unreleased]
|
||||
### Added
|
||||
- An option `unmute-on-scroll` for `internal/pulseaudio` and `internal/alsa` to unmute audio when the user scrolls on the widget.
|
||||
- Added support for ephemeral network interfaces, with rudimentary wireguard support ([`#1164`](https://github.com/polybar/polybar/issues/1164), [`#1531`](https://github.com/polybar/polybar/issues/1531), [`#2980`](https://github.com/polybar/polybar/pull/2980)) by [@Swivelgames](https://github.com/Swivelgames).
|
||||
|
||||
## [3.7.1] - 2023-11-27
|
||||
### Build
|
||||
|
|
|
@ -104,6 +104,7 @@ namespace net {
|
|||
link_status m_status{};
|
||||
string m_interface;
|
||||
bool m_tuntap{false};
|
||||
bool m_wireguard{false};
|
||||
bool m_bridge{false};
|
||||
bool m_unknown_up{false};
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace modules {
|
|||
explicit network_module(const bar_settings&, string, const config&);
|
||||
|
||||
void teardown();
|
||||
void setup();
|
||||
bool update();
|
||||
string get_format() const;
|
||||
bool build(builder* builder, const string& tag) const;
|
||||
|
@ -45,6 +46,7 @@ namespace modules {
|
|||
|
||||
atomic<bool> m_connected{false};
|
||||
atomic<bool> m_packetloss{false};
|
||||
atomic<bool> m_setup{false};
|
||||
|
||||
int m_signal{0};
|
||||
int m_quality{0};
|
||||
|
|
|
@ -324,6 +324,11 @@ namespace net {
|
|||
m_tuntap = false;
|
||||
}
|
||||
|
||||
if (strncmp(driver.driver, "wireguard", 9) == 0) {
|
||||
m_tuntap = true;
|
||||
m_wireguard = true;
|
||||
}
|
||||
|
||||
if (strncmp(driver.driver, "bridge", 6) == 0) {
|
||||
m_bridge = true;
|
||||
}
|
||||
|
@ -408,6 +413,10 @@ namespace net {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (m_wireguard) {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct ethtool_value data {};
|
||||
struct ifreq request {};
|
||||
|
||||
|
|
|
@ -40,18 +40,6 @@ namespace modules {
|
|||
throw module_error("Missing 'interface' or 'interface-type'");
|
||||
}
|
||||
|
||||
if (!net::is_interface_valid(m_interface)) {
|
||||
throw module_error("Invalid network interface \"" + m_interface + "\"");
|
||||
}
|
||||
|
||||
auto canonical = net::get_canonical_interface(m_interface);
|
||||
|
||||
if (canonical.second) {
|
||||
m_log.info(
|
||||
"%s: Replacing given interface '%s' with its canonical name '%s'", name(), m_interface, canonical.first);
|
||||
m_interface = canonical.first;
|
||||
}
|
||||
|
||||
m_ping_nth_update = m_conf.get(name(), "ping-interval", m_ping_nth_update);
|
||||
m_udspeed_minwidth = m_conf.get(name(), "udspeed-minwidth", m_udspeed_minwidth);
|
||||
m_accumulate = m_conf.get(name(), "accumulate-stats", m_accumulate);
|
||||
|
@ -97,15 +85,6 @@ namespace modules {
|
|||
}
|
||||
}
|
||||
|
||||
// Get an intstance of the network interface
|
||||
if (net::is_wireless_interface(m_interface)) {
|
||||
m_wireless = std::make_unique<net::wireless_network>(m_interface);
|
||||
m_wireless->set_unknown_up(m_unknown_up);
|
||||
} else {
|
||||
m_wired = std::make_unique<net::wired_network>(m_interface);
|
||||
m_wired->set_unknown_up(m_unknown_up);
|
||||
};
|
||||
|
||||
// We only need to start the subthread if the packetloss animation is used
|
||||
if (m_animation_packetloss) {
|
||||
m_threads.emplace_back(thread(&network_module::subthread_routine, this));
|
||||
|
@ -117,14 +96,48 @@ namespace modules {
|
|||
m_wired.reset();
|
||||
}
|
||||
|
||||
void network_module::setup() {
|
||||
m_log.warn("%s: Setting up interface", name(), m_interface);
|
||||
auto canonical = net::get_canonical_interface(m_interface);
|
||||
|
||||
if (canonical.second) {
|
||||
m_log.info(
|
||||
"%s: Replacing given interface '%s' with its canonical name '%s'", name(), m_interface, canonical.first);
|
||||
m_interface = canonical.first;
|
||||
}
|
||||
|
||||
// Get an instance of the network interface
|
||||
if (net::is_wireless_interface(m_interface)) {
|
||||
m_wireless = std::make_unique<net::wireless_network>(m_interface);
|
||||
m_wireless->set_unknown_up(m_unknown_up);
|
||||
} else {
|
||||
m_wired = std::make_unique<net::wired_network>(m_interface);
|
||||
m_wired->set_unknown_up(m_unknown_up);
|
||||
};
|
||||
|
||||
m_setup = true;
|
||||
}
|
||||
|
||||
bool network_module::update() {
|
||||
if (!net::is_interface_valid(m_interface)) {
|
||||
// If the interface doesn't exist, it might be ephemeral
|
||||
m_setup = false;
|
||||
m_connected = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// The interface exists, but are we ready for it?
|
||||
if (!m_setup) {
|
||||
setup();
|
||||
}
|
||||
|
||||
net::network* network =
|
||||
m_wireless ? static_cast<net::network*>(m_wireless.get()) : static_cast<net::network*>(m_wired.get());
|
||||
|
||||
if (!network->query(m_accumulate)) {
|
||||
m_log.warn("%s: Failed to query interface '%s'", name(), m_interface);
|
||||
m_connected = false;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue