mirror of
https://github.com/polybar/polybar.git
synced 2026-03-01 01:15:39 +00:00
fix(net): Use canonical interface name (#2540)
One can define an 'altname' for an interface. That name is valid of if_nametoindex but it doesn't appear in `/sys/class/net`: ``` sudo ip link property add dev enp0s31f6 altname eno ``` This creates an altname eno for the existing interface enp0s31f6 Before, using eno, would lead to an error in `realpath`. Ref: https://www.reddit.com/r/Polybar/comments/q8f0ye/error_disabling_module_network_reason_realpath/hgqpq1m/?context=3
This commit is contained in:
@ -44,6 +44,14 @@ namespace modules {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user