From 8c57eab5e6cb0c95b56089f9d804cb07a2fb2073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 30 Aug 2023 23:56:30 +0200 Subject: [PATCH] status/bluetooth: Only show when rfkill is available We currently show the bluetooth toggle when Bluetooth can be toggled via rfkill, or when there is a powered adapter. While the latter condition is obvious - if there is a working Bluetooth adapter, then Bluetooth is available - it does impose a problem: We rely on rfkill for turning Bluetooth off, so if rfkill is missing, the toggle is stuck. We could handle that case and power off the adapter ourselves when necessary, but then the toggle would just disappear when turned off. Instead, only show the toggle when rfkill is available, so we can assume that turning Bluetooth on and off will work. This is also consistent with Settings, which shows Bluetooth as unavailable in this case. Part-of: --- js/ui/status/bluetooth.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index d398f717f..1584e0468 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -47,7 +47,6 @@ const BtClient = GObject.registerClass({ this._client = new GnomeBluetooth.Client(); this._client.connect('notify::default-adapter-powered', () => { this.notify('active'); - this.notify('available'); }); this._client.connect('notify::default-adapter-state', () => this.notify('adapter-state')); @@ -59,7 +58,6 @@ const BtClient = GObject.registerClass({ this.emit('devices-changed'); this.notify('active'); - this.notify('available'); }); this._proxy = new Gio.DBusProxy({ @@ -101,9 +99,8 @@ const BtClient = GObject.registerClass({ get available() { // If we have an rfkill switch, make sure it's not a hardware // one as we can't get out of it in software - return this._proxy.BluetoothHasAirplaneMode - ? !this._proxy.BluetoothHardwareAirplaneMode - : this.active; + return this._proxy.BluetoothHasAirplaneMode && + !this._proxy.BluetoothHardwareAirplaneMode; } get active() {