diff --git a/blueman/plugins/applet/AutoConnect.py b/blueman/plugins/applet/AutoConnect.py index 9e84ac7ce..659faf611 100644 --- a/blueman/plugins/applet/AutoConnect.py +++ b/blueman/plugins/applet/AutoConnect.py @@ -1,11 +1,12 @@ from gettext import gettext as _ from typing import TYPE_CHECKING, Union, Optional, Any -from blueman.bluemantyping import ObjectPath +from blueman.bluemantyping import ObjectPath, BtAddress from gi.repository import GLib from blueman.Sdp import ServiceUUID from blueman.bluez.Device import Device +from blueman.config.AutoConnectConfig import AutoConnectConfig from blueman.gui.Notification import Notification from blueman.plugins.AppletPlugin import AppletPlugin @@ -40,8 +41,24 @@ def on_adapter_property_changed(self, path: ObjectPath, key: str, value: Any) -> if key == "Powered" and value: self._run() + @staticmethod + def __fix_settings(path: ObjectPath, uuid: str) -> BtAddress: + config = AutoConnectConfig() + address = path.replace("_", ":")[-17:] + + data = set(config["services"]) + data.remove((path, uuid)) + data.add((address, uuid)) + config["services"] = data + + return BtAddress(address) + def _run(self) -> bool: for btaddress, uuid in self.get_option('services'): + # We accidentally stored the dbus object path in 2.4 + if btaddress.startswith("/org/bluez"): + btaddress = self.__fix_settings(btaddress, uuid) + device = self.parent.Manager.find_device(btaddress) if device is None or device.get("Connected"): continue