Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bluetooth log spamming #4632

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions libqtile/widget/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ def _catch_dbus_error(msg):
"""Decorator to catch DBusErrors and log a message."""

def _wrapper(func):
async def f(self):
async def f(self, *args, **kwargs):
try:
await func(self)
await func(self, *args, **kwargs)
except DBusError:
logger.warning(msg, self.name)
except BlockingIOError:
logger.debug("DBus resource is temporarily unavailable.")
pass

return f

Expand Down Expand Up @@ -118,6 +121,7 @@ async def pair_and_connect(self):
await self.interface.call_pair()
await self.connect()

@_catch_dbus_error("Unable to call action: %s.")
async def action(self):
"""Helper method to call appropriate method based on device status."""
if self.connected:
Expand Down Expand Up @@ -171,11 +175,13 @@ def remove_battery(self):
self.battery_device = None
self._battery = 0

@_catch_dbus_error("Unable to get battery device: %s.")
async def get_battery(self):
proxy = await self.widget.get_proxy(self.path)
with contextlib.suppress(InterfaceNotFoundError):
self.battery_device = proxy.get_interface(BLUEZ_BATTERY)

@_catch_dbus_error("Unable to update properties: %s.")
async def update_props(self, setup=False):
"""Refresh all the properties for the device."""
# Some devices don't report a name so we fall back to the device address
Expand Down Expand Up @@ -262,12 +268,14 @@ def powered(self):
def name(self):
return self._name

@_catch_dbus_error("Unable to update discovery status: %s.")
async def discover(self):
if self.discovering:
await self.stop_discovery()
else:
await self.start_discovery()

@_catch_dbus_error("Unable to update properties: %s.")
async def update_props(self, setup=False):
self._discovering = await self.interface.get_discovering()
self._powered = await self.interface.get_powered()
Expand Down