From 6d9d325eca0c04c4ba2931f76a51bd34ed623686 Mon Sep 17 00:00:00 2001 From: Marvin Steadfast Date: Tue, 30 Jun 2020 14:49:43 +0200 Subject: [PATCH] [modules/nic] Using `iw` to find out whats the SSID name --- bumblebee_status/modules/core/nic.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bumblebee_status/modules/core/nic.py b/bumblebee_status/modules/core/nic.py index 585c65f..75bcd77 100644 --- a/bumblebee_status/modules/core/nic.py +++ b/bumblebee_status/modules/core/nic.py @@ -12,6 +12,7 @@ Parameters: * nic.format: Format string (defaults to '{intf} {state} {ip} {ssid}') """ +import re import shutil import netifaces import subprocess @@ -44,7 +45,7 @@ class Module(core.module.Module): else: self._states["include"].append(state) self._format = self.parameter("format", "{intf} {state} {ip} {ssid}") - self.iwgetid = shutil.which("iwgetid") + self.iw = shutil.which("iw") self._update_widgets(widgets) def update(self): @@ -125,10 +126,13 @@ class Module(core.module.Module): widget.set("state", state) def get_ssid(self, intf): - if self._iswlan(intf) and not self._istunnel(intf) and self.iwgetid: - return util.cli.execute( - "{} -r {}".format(self.iwgetid, intf), ignore_errors=True - ) + if self._iswlan(intf) and not self._istunnel(intf) and self.iw: + ssid = util.cli.execute("{} dev {} link".format(self.iw, intf)) + found_ssid = re.findall("SSID:\s(.+)", ssid) + if len(found_ssid) > 0: + return found_ssid[0] + else: + return "" return ""