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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2815>
This commit is contained in:
Florian Müllner 2023-08-30 23:56:30 +02:00 committed by Marge Bot
parent f5292fd024
commit 8c57eab5e6

View File

@ -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() {