fix(controlcenter): flush stale-cache races in toggle UI
- Drop rfkill from bluetooth toggle (redundant with D-Bus Powered, was causing stale cache on next read) - Force toggle switch and icon to target state immediately after setting, don't wait for D-Bus callback - Fix nightlight icon race: flip local is_active instead of re-querying async kill state - Guard wifi on_network_ready against ethernet-first device loop (emits device-ready per device; wifi_device None on first) - Share single NetworkClient between main panel and wifi popup (eliminates async-init race of two independent instances) - Strip connected: prefix from wlan label initial display - Add _pending_toggle pattern to wifi notify handler to suppress stale-cache revert; same for bluetooth switch lock
This commit is contained in:
4 files changed
+78
-64
No files matched your search
@@ -1,6 +1,6 @@
|
||||
from enum import Enum, auto
|
||||
|
||||
from fabric.utils import Gdk, GLib, Gtk, exec_shell_command, logger
|
||||
from fabric.utils import Gdk, GLib, Gtk, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.centerbox import CenterBox
|
||||
@@ -46,17 +46,6 @@ def get_battery_theme_icon(percentage: float, charging: bool = False) -> str:
|
||||
|
||||
|
||||
def set_bluetooth_enabled_with_fallback(client, enabled: bool):
|
||||
if enabled:
|
||||
command = "rfkill unblock bluetooth"
|
||||
else:
|
||||
command = "rfkill block bluetooth"
|
||||
|
||||
result = exec_shell_command(command)
|
||||
if result is False:
|
||||
logger.error(f"rfkill fallback failed: command '{command}' returned False")
|
||||
elif isinstance(result, str) and result.strip():
|
||||
logger.warning(f"rfkill command output: {result.strip()}")
|
||||
|
||||
try:
|
||||
if hasattr(client, "set_enabled"):
|
||||
client.set_enabled(enabled)
|
||||
@@ -481,6 +470,7 @@ class BluetoothConnections(Box):
|
||||
def handle_user_toggle(self, active: bool):
|
||||
self._switch_lock = True
|
||||
set_bluetooth_enabled_with_fallback(self.client, active)
|
||||
self.toggle_button.set_active(active)
|
||||
GLib.timeout_add(1500, self._unlock_switch)
|
||||
|
||||
def _unlock_switch(self):
|
||||
|
||||
Reference in new issue
Block a user