We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bluetooth widget displays adapter name instead of name of connected device
### The issue:

version: 0.21.0
log: no relevant log

I configured the bluetooth-widget.
When a device is connected, it shows the adapter name, instead of the device name.

### Required:

- [X] I have searched past issues to see if this bug has already been reported.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `libqtile/widget/bluetooth.py`
Content:
```
1 # Copyright (c) 2021 Graeme Holliday
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
20 
21 from dbus_next.aio import MessageBus
22 from dbus_next.constants import BusType
23 
24 from libqtile.widget import base
25 
26 BLUEZ = "org.bluez"
27 BLUEZ_PATH = "/org/bluez/hci0"
28 BLUEZ_ADAPTER = "org.bluez.Adapter1"
29 BLUEZ_DEVICE = "org.bluez.Device1"
30 BLUEZ_PROPERTIES = "org.freedesktop.DBus.Properties"
31 
32 
33 class Bluetooth(base._TextBox):
34     """
35     Displays bluetooth status for a particular connected device.
36 
37     (For example your bluetooth headphones.)
38 
39     Uses dbus-next to communicate with the system bus.
40 
41     Widget requirements: dbus-next_.
42 
43     .. _dbus-next: https://pypi.org/project/dbus-next/
44     """
45 
46     defaults = [
47         (
48             "hci",
49             "/dev_XX_XX_XX_XX_XX_XX",
50             "hci0 device path, can be found with d-feet or similar dbus explorer.",
51         )
52     ]
53 
54     def __init__(self, **config):
55         base._TextBox.__init__(self, "", **config)
56         self.add_defaults(Bluetooth.defaults)
57 
58     async def _config_async(self):
59         # set initial values
60         self.powered = await self._init_adapter()
61         self.connected, self.device = await self._init_device()
62 
63         self.update_text()
64 
65     async def _init_adapter(self):
66         # set up interface to adapter properties using high-level api
67         bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
68         introspect = await bus.introspect(BLUEZ, BLUEZ_PATH)
69         obj = bus.get_proxy_object(BLUEZ, BLUEZ_PATH, introspect)
70         iface = obj.get_interface(BLUEZ_ADAPTER)
71         props = obj.get_interface(BLUEZ_PROPERTIES)
72 
73         powered = await iface.get_powered()
74         # subscribe receiver to property changed
75         props.on_properties_changed(self._signal_received)
76         return powered
77 
78     async def _init_device(self):
79         # set up interface to device properties using high-level api
80         bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
81         introspect = await bus.introspect(BLUEZ, BLUEZ_PATH + self.hci)
82         obj = bus.get_proxy_object(BLUEZ, BLUEZ_PATH + self.hci, introspect)
83         iface = obj.get_interface(BLUEZ_DEVICE)
84         props = obj.get_interface(BLUEZ_PROPERTIES)
85 
86         connected = await iface.get_connected()
87         name = await iface.get_name()
88         # subscribe receiver to property changed
89         props.on_properties_changed(self._signal_received)
90         return connected, name
91 
92     def _signal_received(self, interface_name, changed_properties, _invalidated_properties):
93         powered = changed_properties.get("Powered", None)
94         if powered is not None:
95             self.powered = powered.value
96             self.update_text()
97 
98         connected = changed_properties.get("Connected", None)
99         if connected is not None:
100             self.connected = connected.value
101             self.update_text()
102 
103         device = changed_properties.get("Name", None)
104         if device is not None:
105             self.device = device.value
106             self.update_text()
107 
108     def update_text(self):
109         text = ""
110         if not self.powered:
111             text = "off"
112         else:
113             if not self.connected:
114                 text = "on"
115             else:
116                 text = self.device
117         self.update(text)
118
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/libqtile/widget/bluetooth.py b/libqtile/widget/bluetooth.py
--- a/libqtile/widget/bluetooth.py
+++ b/libqtile/widget/bluetooth.py
@@ -72,7 +72,7 @@
 
         powered = await iface.get_powered()
         # subscribe receiver to property changed
-        props.on_properties_changed(self._signal_received)
+        props.on_properties_changed(self._adapter_signal_received)
         return powered
 
     async def _init_device(self):
@@ -86,15 +86,20 @@
         connected = await iface.get_connected()
         name = await iface.get_name()
         # subscribe receiver to property changed
-        props.on_properties_changed(self._signal_received)
+        props.on_properties_changed(self._device_signal_received)
         return connected, name
 
-    def _signal_received(self, interface_name, changed_properties, _invalidated_properties):
+    def _adapter_signal_received(
+        self, interface_name, changed_properties, _invalidated_properties
+    ):
         powered = changed_properties.get("Powered", None)
         if powered is not None:
             self.powered = powered.value
             self.update_text()
 
+    def _device_signal_received(
+        self, interface_name, changed_properties, _invalidated_properties
+    ):
         connected = changed_properties.get("Connected", None)
         if connected is not None:
             self.connected = connected.value

{"golden_diff": "diff --git a/libqtile/widget/bluetooth.py b/libqtile/widget/bluetooth.py\n--- a/libqtile/widget/bluetooth.py\n+++ b/libqtile/widget/bluetooth.py\n@@ -72,7 +72,7 @@\n \n         powered = await iface.get_powered()\n         # subscribe receiver to property changed\n-        props.on_properties_changed(self._signal_received)\n+        props.on_properties_changed(self._adapter_signal_received)\n         return powered\n \n     async def _init_device(self):\n@@ -86,15 +86,20 @@\n         connected = await iface.get_connected()\n         name = await iface.get_name()\n         # subscribe receiver to property changed\n-        props.on_properties_changed(self._signal_received)\n+        props.on_properties_changed(self._device_signal_received)\n         return connected, name\n \n-    def _signal_received(self, interface_name, changed_properties, _invalidated_properties):\n+    def _adapter_signal_received(\n+        self, interface_name, changed_properties, _invalidated_properties\n+    ):\n         powered = changed_properties.get(\"Powered\", None)\n         if powered is not None:\n             self.powered = powered.value\n             self.update_text()\n \n+    def _device_signal_received(\n+        self, interface_name, changed_properties, _invalidated_properties\n+    ):\n         connected = changed_properties.get(\"Connected\", None)\n         if connected is not None:\n             self.connected = connected.value\n", "issue": "Bluetooth widget displays adapter name instead of name of connected device\n### The issue:\n\nversion: 0.21.0\r\nlog: no relevant log\r\n\r\nI configured the bluetooth-widget.\r\nWhen a device is connected, it shows the adapter name, instead of the device name.\n\n### Required:\n\n- [X] I have searched past issues to see if this bug has already been reported.\n", "before_files": [{"content": "# Copyright (c) 2021 Graeme Holliday\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom dbus_next.aio import MessageBus\nfrom dbus_next.constants import BusType\n\nfrom libqtile.widget import base\n\nBLUEZ = \"org.bluez\"\nBLUEZ_PATH = \"/org/bluez/hci0\"\nBLUEZ_ADAPTER = \"org.bluez.Adapter1\"\nBLUEZ_DEVICE = \"org.bluez.Device1\"\nBLUEZ_PROPERTIES = \"org.freedesktop.DBus.Properties\"\n\n\nclass Bluetooth(base._TextBox):\n    \"\"\"\n    Displays bluetooth status for a particular connected device.\n\n    (For example your bluetooth headphones.)\n\n    Uses dbus-next to communicate with the system bus.\n\n    Widget requirements: dbus-next_.\n\n    .. _dbus-next: https://pypi.org/project/dbus-next/\n    \"\"\"\n\n    defaults = [\n        (\n            \"hci\",\n            \"/dev_XX_XX_XX_XX_XX_XX\",\n            \"hci0 device path, can be found with d-feet or similar dbus explorer.\",\n        )\n    ]\n\n    def __init__(self, **config):\n        base._TextBox.__init__(self, \"\", **config)\n        self.add_defaults(Bluetooth.defaults)\n\n    async def _config_async(self):\n        # set initial values\n        self.powered = await self._init_adapter()\n        self.connected, self.device = await self._init_device()\n\n        self.update_text()\n\n    async def _init_adapter(self):\n        # set up interface to adapter properties using high-level api\n        bus = await MessageBus(bus_type=BusType.SYSTEM).connect()\n        introspect = await bus.introspect(BLUEZ, BLUEZ_PATH)\n        obj = bus.get_proxy_object(BLUEZ, BLUEZ_PATH, introspect)\n        iface = obj.get_interface(BLUEZ_ADAPTER)\n        props = obj.get_interface(BLUEZ_PROPERTIES)\n\n        powered = await iface.get_powered()\n        # subscribe receiver to property changed\n        props.on_properties_changed(self._signal_received)\n        return powered\n\n    async def _init_device(self):\n        # set up interface to device properties using high-level api\n        bus = await MessageBus(bus_type=BusType.SYSTEM).connect()\n        introspect = await bus.introspect(BLUEZ, BLUEZ_PATH + self.hci)\n        obj = bus.get_proxy_object(BLUEZ, BLUEZ_PATH + self.hci, introspect)\n        iface = obj.get_interface(BLUEZ_DEVICE)\n        props = obj.get_interface(BLUEZ_PROPERTIES)\n\n        connected = await iface.get_connected()\n        name = await iface.get_name()\n        # subscribe receiver to property changed\n        props.on_properties_changed(self._signal_received)\n        return connected, name\n\n    def _signal_received(self, interface_name, changed_properties, _invalidated_properties):\n        powered = changed_properties.get(\"Powered\", None)\n        if powered is not None:\n            self.powered = powered.value\n            self.update_text()\n\n        connected = changed_properties.get(\"Connected\", None)\n        if connected is not None:\n            self.connected = connected.value\n            self.update_text()\n\n        device = changed_properties.get(\"Name\", None)\n        if device is not None:\n            self.device = device.value\n            self.update_text()\n\n    def update_text(self):\n        text = \"\"\n        if not self.powered:\n            text = \"off\"\n        else:\n            if not self.connected:\n                text = \"on\"\n            else:\n                text = self.device\n        self.update(text)\n", "path": "libqtile/widget/bluetooth.py"}], "after_files": [{"content": "# Copyright (c) 2021 Graeme Holliday\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom dbus_next.aio import MessageBus\nfrom dbus_next.constants import BusType\n\nfrom libqtile.widget import base\n\nBLUEZ = \"org.bluez\"\nBLUEZ_PATH = \"/org/bluez/hci0\"\nBLUEZ_ADAPTER = \"org.bluez.Adapter1\"\nBLUEZ_DEVICE = \"org.bluez.Device1\"\nBLUEZ_PROPERTIES = \"org.freedesktop.DBus.Properties\"\n\n\nclass Bluetooth(base._TextBox):\n    \"\"\"\n    Displays bluetooth status for a particular connected device.\n\n    (For example your bluetooth headphones.)\n\n    Uses dbus-next to communicate with the system bus.\n\n    Widget requirements: dbus-next_.\n\n    .. _dbus-next: https://pypi.org/project/dbus-next/\n    \"\"\"\n\n    defaults = [\n        (\n            \"hci\",\n            \"/dev_XX_XX_XX_XX_XX_XX\",\n            \"hci0 device path, can be found with d-feet or similar dbus explorer.\",\n        )\n    ]\n\n    def __init__(self, **config):\n        base._TextBox.__init__(self, \"\", **config)\n        self.add_defaults(Bluetooth.defaults)\n\n    async def _config_async(self):\n        # set initial values\n        self.powered = await self._init_adapter()\n        self.connected, self.device = await self._init_device()\n\n        self.update_text()\n\n    async def _init_adapter(self):\n        # set up interface to adapter properties using high-level api\n        bus = await MessageBus(bus_type=BusType.SYSTEM).connect()\n        introspect = await bus.introspect(BLUEZ, BLUEZ_PATH)\n        obj = bus.get_proxy_object(BLUEZ, BLUEZ_PATH, introspect)\n        iface = obj.get_interface(BLUEZ_ADAPTER)\n        props = obj.get_interface(BLUEZ_PROPERTIES)\n\n        powered = await iface.get_powered()\n        # subscribe receiver to property changed\n        props.on_properties_changed(self._adapter_signal_received)\n        return powered\n\n    async def _init_device(self):\n        # set up interface to device properties using high-level api\n        bus = await MessageBus(bus_type=BusType.SYSTEM).connect()\n        introspect = await bus.introspect(BLUEZ, BLUEZ_PATH + self.hci)\n        obj = bus.get_proxy_object(BLUEZ, BLUEZ_PATH + self.hci, introspect)\n        iface = obj.get_interface(BLUEZ_DEVICE)\n        props = obj.get_interface(BLUEZ_PROPERTIES)\n\n        connected = await iface.get_connected()\n        name = await iface.get_name()\n        # subscribe receiver to property changed\n        props.on_properties_changed(self._device_signal_received)\n        return connected, name\n\n    def _adapter_signal_received(\n        self, interface_name, changed_properties, _invalidated_properties\n    ):\n        powered = changed_properties.get(\"Powered\", None)\n        if powered is not None:\n            self.powered = powered.value\n            self.update_text()\n\n    def _device_signal_received(\n        self, interface_name, changed_properties, _invalidated_properties\n    ):\n        connected = changed_properties.get(\"Connected\", None)\n        if connected is not None:\n            self.connected = connected.value\n            self.update_text()\n\n        device = changed_properties.get(\"Name\", None)\n        if device is not None:\n            self.device = device.value\n            self.update_text()\n\n    def update_text(self):\n        text = \"\"\n        if not self.powered:\n            text = \"off\"\n        else:\n            if not self.connected:\n                text = \"on\"\n            else:\n                text = self.device\n        self.update(text)\n", "path": "libqtile/widget/bluetooth.py"}]}