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

AutoConnect: Automatically convert path to address #2494

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion blueman/plugins/applet/AutoConnect.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down