Skip to content

Commit

Permalink
Merge pull request #1010 from DrBu7cher/fix-nic-include
Browse files Browse the repository at this point in the history
fix(modules,core,nix): respect include and exclude correctly when using multiple aliases
  • Loading branch information
tobi-wan-kenobi authored Feb 27, 2024
2 parents fd0714e + af20834 commit 65ee40b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bumblebee_status/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def clear_widgets(self):
"""

def add_widget(self, full_text="", name=None, hidden=False):
widget_id = "{}::{}".format(self.name, len(self.widgets()))
widget_id = "{}::{}".format(self.id, len(self.widgets()))
widget = core.widget.Widget(full_text=full_text, name=name, widget_id=widget_id, hidden=hidden)
self.widgets().append(widget)
widget.module = self
Expand Down
14 changes: 10 additions & 4 deletions bumblebee_status/modules/core/nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def __init__(self, config, theme):
self._exclude = util.format.aslist(
self.parameter("exclude", "lo,virbr,docker,vboxnet,veth,br,.*:avahi")
)
self._include = util.format.aslist(self.parameter("include", ""))

include_parameter = self.parameter("include", "")
self._include = util.format.aslist(include_parameter) if include_parameter else []

self._states = {"include": [], "exclude": []}
for state in tuple(
Expand Down Expand Up @@ -88,7 +90,7 @@ def state(self, widget):

def _iswlan(self, intf):
# wifi, wlan, wlp, seems to work for me
if intf.startswith("w"):
if intf.startswith("w") and not intf.startswith("wg"):
return True
return False

Expand All @@ -105,6 +107,11 @@ def get_addresses(self, intf):
return []
return retval

def _included(self, intf):
if not self._include:
return True
return intf in self._include

def _excluded(self, intf):
for e in self._exclude:
if re.match(e, intf):
Expand All @@ -115,9 +122,8 @@ def _update_widgets(self, widgets):
self.clear_widgets()
interfaces = []
for i in netifaces.interfaces():
if not self._excluded(i):
if not self._excluded(i) and self._included(i):
interfaces.append(i)
interfaces.extend([i for i in netifaces.interfaces() if i in self._include])

for intf in interfaces:
addr = []
Expand Down

0 comments on commit 65ee40b

Please sign in to comment.