def _get_adapter_menu(self, adapter):
        """Builds a submenu for the selected adapter."""
        state = "off" if adapter.powered else "on"
        discovery = "off" if adapter.discovering else "on"

        def exit():
            self.show_adapter = False
            # Restore menu position
            self._line_index = self._adapter_index
            self.refresh()

        return [
            (f"Turn power {state}", lambda a=adapter: create_task(a.power())),
            (f"Turn discovery {discovery}", lambda a=adapter: create_task(a.discover())),
            ("Exit", lambda: exit()),
        ]
Builds a submenu for the selected adapter.
libqtile/widget/bluetooth.py