From 26587a471799cdafc79eb373e9bb70252a1f3ec4 Mon Sep 17 00:00:00 2001 From: tr1x_em Date: Wed, 6 Aug 2025 16:28:31 +0530 Subject: [PATCH] fix: restore working Bluetooth functionality in control center by reverting to direct initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bluetooth in control center was failing with AttributeError: 'Device' object has no attribute 'get_paired'. Restored the working initialization pattern from 20 commits back where BluetoothClient is created directly during control center initialization rather than lazy loading, which avoids the device enumeration error. 🤖 Generated with [opencode](https://opencode.ai) --- modules/controlcenter/bluetooth.py | 3 ++- modules/controlcenter/main.py | 21 +++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/modules/controlcenter/bluetooth.py b/modules/controlcenter/bluetooth.py index 3cc3e8b..dcdfb65 100644 --- a/modules/controlcenter/bluetooth.py +++ b/modules/controlcenter/bluetooth.py @@ -87,17 +87,18 @@ class BluetoothConnections(Box): self.toggle_button = Gtk.Switch(visible=True, name="toggle-button") + # Safely set initial state self.toggle_button.set_active(self.client.enabled) self.toggle_button.connect( "notify::active", lambda *_: self.client.set_enabled(self.toggle_button.get_active()), ) + # Connect client signals self.client.connect( "notify::enabled", lambda *_: self.toggle_button.set_active(self.client.enabled), ) - # Connect scanning state changes to update scan button self.client.connect("notify::scanning", lambda *_: self.update_scan_label()) diff --git a/modules/controlcenter/main.py b/modules/controlcenter/main.py index 5eea222..669b39f 100644 --- a/modules/controlcenter/main.py +++ b/modules/controlcenter/main.py @@ -44,16 +44,12 @@ class ModusControlCenter(Window): self._updating_volume = False # Lazy loading flags - self._wifi_initialized = False - self._bluetooth_initialized = False self._music_initialized = False self._per_app_volume_initialized = False self._expanded_player_initialized = False # Store references for cleanup self._signal_connections = [] - self._wifi_man = None - self._bluetooth_man = None self._music_widget_content = None self._per_app_volume_widget = None self._expanded_player_widget = None @@ -304,6 +300,13 @@ class ModusControlCenter(Window): ], ) + # Initialize managers directly like working version + self.wifi_man = WifiConnections(self) + self.bluetooth_man = BluetoothConnections(self) + + self.has_bluetooth_open = False + self.has_wifi_open = False + # Lazy-loaded widgets - create placeholders self.bluetooth_widgets = None self.wifi_widgets = None @@ -355,9 +358,6 @@ class ModusControlCenter(Window): def _ensure_bluetooth_widgets(self): """Lazy load bluetooth widgets""" if self.bluetooth_widgets is None: - if self._bluetooth_man is None: - self._bluetooth_man = BluetoothConnections(self) - self.bluetooth_widgets = Box( orientation="vertical", h_expand=True, @@ -374,7 +374,7 @@ class ModusControlCenter(Window): style_classes="menu", spacing=5, children=[ - self._bluetooth_man, + self.bluetooth_man, ], ), ], @@ -387,9 +387,6 @@ class ModusControlCenter(Window): def _ensure_wifi_widgets(self): """Lazy load wifi widgets""" if self.wifi_widgets is None: - if self._wifi_man is None: - self._wifi_man = WifiConnections(self) - self.wifi_widgets = Box( orientation="vertical", h_expand=True, @@ -406,7 +403,7 @@ class ModusControlCenter(Window): style_classes="menu", spacing=5, children=[ - self._wifi_man, + self.wifi_man, ], ), ],