prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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.
  
  </issue>
  <code>
  [start of libqtile/widget/bluetooth.py]
  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 of libqtile/widget/bluetooth.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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
  
verification_info: {"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"}]}