From dc50a8ab51f557792d9f8df0442c9489c12e81e8 Mon Sep 17 00:00:00 2001 From: Guy Freeman Date: Tue, 31 Mar 2026 21:09:36 +0300 Subject: [PATCH 1/2] AutoConnect: Log failed auto-connect attempts Co-Authored-By: Claude Opus 4.6 (1M context) --- blueman/plugins/applet/AutoConnect.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blueman/plugins/applet/AutoConnect.py b/blueman/plugins/applet/AutoConnect.py index e77d0ae4a..a6ed2cb40 100644 --- a/blueman/plugins/applet/AutoConnect.py +++ b/blueman/plugins/applet/AutoConnect.py @@ -1,3 +1,4 @@ +import logging from gettext import gettext as _ from typing import TYPE_CHECKING, Any from blueman.bluemantyping import ObjectPath, BtAddress @@ -69,8 +70,9 @@ def reply(dev: Device | None = device, service_name: str = ServiceUUID(uuid).nam {"service": service_name, "device": dev.display_name}, icon_name=dev["Icon"]).show() - def err(_reason: Exception | str) -> None: - pass + def err(_reason: Exception | str, dev: Device | None = device) -> None: + assert isinstance(dev, Device) + logging.warning(f"AutoConnect failed for {dev.display_name}: {_reason}") self.parent.Plugins.DBusService.connect_service(device.get_object_path(), uuid, reply, err) From a40d58f9b9839b473669c094379940abddcbfe71 Mon Sep 17 00:00:00 2001 From: Guy Freeman Date: Sat, 18 Apr 2026 21:14:14 +0300 Subject: [PATCH 2/2] AutoConnect: Dedupe consecutive identical failures per device Auto-connect retries every ~60s, so a permanently-unreachable device would otherwise emit a warning line every minute forever. Track the last error reason per device address; log only when the reason changes. Clear the entry on a successful connect so a later failure logs again. Co-Authored-By: Claude Opus 4.7 (1M context) --- blueman/plugins/applet/AutoConnect.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/blueman/plugins/applet/AutoConnect.py b/blueman/plugins/applet/AutoConnect.py index a6ed2cb40..06cf67ba7 100644 --- a/blueman/plugins/applet/AutoConnect.py +++ b/blueman/plugins/applet/AutoConnect.py @@ -32,6 +32,7 @@ class AutoConnect(AppletPlugin): def __init__(self, parent: "BluemanApplet"): super().__init__(parent) + self._last_err: dict[str, str] = {} GLib.timeout_add(60000, self._run) def on_manager_state_changed(self, state: bool) -> None: @@ -66,13 +67,19 @@ def _run(self) -> bool: def reply(dev: Device | None = device, service_name: str = ServiceUUID(uuid).name) -> None: assert isinstance(dev, Device) # https://github.com/python/mypy/issues/2608 + self._last_err.pop(dev["Address"], None) Notification(_("Connected"), _("Automatically connected to %(service)s on %(device)s") % {"service": service_name, "device": dev.display_name}, icon_name=dev["Icon"]).show() - def err(_reason: Exception | str, dev: Device | None = device) -> None: + def err(reason: Exception | str, dev: Device | None = device) -> None: assert isinstance(dev, Device) - logging.warning(f"AutoConnect failed for {dev.display_name}: {_reason}") + reason_str = str(reason) + address = dev["Address"] + if self._last_err.get(address) == reason_str: + return + self._last_err[address] = reason_str + logging.warning(f"AutoConnect failed for {dev.display_name}: {reason_str}") self.parent.Plugins.DBusService.connect_service(device.get_object_path(), uuid, reply, err)