From 19bf5de78c71ca99e01c60e28586d72f31c6604a Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 30 Aug 2026 19:54:47 -0500 Subject: [PATCH 1/2] feat(widgets/bluetooth): Add option to hide widget when adapter is off This adds a new `hide_when_adapter_off` option to the Bluetooth widget, which hides the Bluetooth widget when the adapter is powered off. --- assets/translations/en.json | 4 ++++ docs/user/bar/widgets/bluetooth.mdx | 1 + src/shell/bar/widgets/bluetooth_widget.cpp | 5 +++-- src/shell/bar/widgets/bluetooth_widget.h | 2 ++ src/shell/bar/widgets/bluetooth_widget_definition.cpp | 3 +++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index f4240284a3..ac3223a4db 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -3545,6 +3545,10 @@ "description": "Hide tray items whose StatusNotifierItem status is Passive", "label": "Hide Passive Items" }, + "hide-when-adapter-off": { + "description": "Hide the Bluetooth widget when adapter is powered off", + "label": "Hide When Off" + }, "hide-when-empty": { "description": "Hide workspace pills when there are no open windows", "label": "Hide When Empty", diff --git a/docs/user/bar/widgets/bluetooth.mdx b/docs/user/bar/widgets/bluetooth.mdx index 52475d94fe..8dc97de69d 100644 --- a/docs/user/bar/widgets/bluetooth.mdx +++ b/docs/user/bar/widgets/bluetooth.mdx @@ -10,6 +10,7 @@ Shows the Bluetooth adapter state and connected device. Left-click opens the Blu | Setting | Type | Default | Description | |---------|------|---------|-------------| | `show_label` | bool | `false` | Show the connected device name next to the icon | +| `hide_when_adapter_off` | bool | `false` | Hide the widget when Bluetooth is disabled | | `hide_when_no_connected_device` | bool | `false` | Hide the widget when no Bluetooth device is connected. | ```toml diff --git a/src/shell/bar/widgets/bluetooth_widget.cpp b/src/shell/bar/widgets/bluetooth_widget.cpp index 0bc3991476..388d410222 100644 --- a/src/shell/bar/widgets/bluetooth_widget.cpp +++ b/src/shell/bar/widgets/bluetooth_widget.cpp @@ -45,7 +45,7 @@ namespace { } // namespace BluetoothWidget::BluetoothWidget(BluetoothService* bluetooth, wl_output* /*output*/, Options options) - : m_bluetooth(bluetooth), m_showLabel(options.showLabel), + : m_bluetooth(bluetooth), m_showLabel(options.showLabel), m_hideWhenAdapterOff(options.hideWhenAdapterOff), m_hideWhenNoConnectedDevice(options.hideWhenNoConnectedDevice) {} void BluetoothWidget::create() { @@ -128,7 +128,8 @@ void BluetoothWidget::syncState(Renderer& renderer) { m_lastConnectedAlias = alias; const bool hasConnectedDevice = numConnected > 0; - const bool showWidget = s.adapterPresent && (!m_hideWhenNoConnectedDevice || hasConnectedDevice); + const bool showWidget = + s.adapterPresent && (!m_hideWhenAdapterOff || s.powered) && (!m_hideWhenNoConnectedDevice || hasConnectedDevice); syncWidgetVisibility(showWidget); if (!showWidget) { if (Node* rootNode = root(); rootNode != nullptr) { diff --git a/src/shell/bar/widgets/bluetooth_widget.h b/src/shell/bar/widgets/bluetooth_widget.h index 1b85febc4a..5557f83d0c 100644 --- a/src/shell/bar/widgets/bluetooth_widget.h +++ b/src/shell/bar/widgets/bluetooth_widget.h @@ -13,6 +13,7 @@ class BluetoothWidget : public Widget { public: struct Options { bool showLabel = false; + bool hideWhenAdapterOff = false; bool hideWhenNoConnectedDevice = false; }; @@ -28,6 +29,7 @@ class BluetoothWidget : public Widget { BluetoothService* m_bluetooth = nullptr; bool m_showLabel = false; + bool m_hideWhenAdapterOff = false; bool m_hideWhenNoConnectedDevice = false; Glyph* m_glyph = nullptr; Label* m_label = nullptr; diff --git a/src/shell/bar/widgets/bluetooth_widget_definition.cpp b/src/shell/bar/widgets/bluetooth_widget_definition.cpp index 50438ac800..e41613b00f 100644 --- a/src/shell/bar/widgets/bluetooth_widget_definition.cpp +++ b/src/shell/bar/widgets/bluetooth_widget_definition.cpp @@ -10,6 +10,9 @@ const noctalia::bar::WidgetDefinition& bluetoothWidget field<&Options::showLabel>({ .key = "show_label", }), + field<&Options::hideWhenAdapterOff>({ + .key = "hide_when_adapter_off", + }), field<&Options::hideWhenNoConnectedDevice>({ .key = "hide_when_no_connected_device", }), From c46c74881f6fb23c9ec9396fecd102d38c95c8fb Mon Sep 17 00:00:00 2001 From: Lemmy Date: Tue, 1 Sep 2026 21:19:17 -0400 Subject: [PATCH 2/2] fix(widgets/bluetooth): gate hide-when-adapter-off on connected-device filter --- assets/translations/en.json | 2 +- docs/user/bar/widgets/bluetooth.mdx | 2 +- .../bar/widgets/bluetooth_widget_definition.cpp | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index ac3223a4db..8d42f52e72 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -3547,7 +3547,7 @@ }, "hide-when-adapter-off": { "description": "Hide the Bluetooth widget when adapter is powered off", - "label": "Hide When Off" + "label": "Hide When Adapter Off" }, "hide-when-empty": { "description": "Hide workspace pills when there are no open windows", diff --git a/docs/user/bar/widgets/bluetooth.mdx b/docs/user/bar/widgets/bluetooth.mdx index 8dc97de69d..c713bf2481 100644 --- a/docs/user/bar/widgets/bluetooth.mdx +++ b/docs/user/bar/widgets/bluetooth.mdx @@ -10,7 +10,7 @@ Shows the Bluetooth adapter state and connected device. Left-click opens the Blu | Setting | Type | Default | Description | |---------|------|---------|-------------| | `show_label` | bool | `false` | Show the connected device name next to the icon | -| `hide_when_adapter_off` | bool | `false` | Hide the widget when Bluetooth is disabled | +| `hide_when_adapter_off` | bool | `false` | Hide the widget when the adapter is powered off. While hidden, the widget's right-click power toggle is unavailable; re-enable Bluetooth from the control center. | | `hide_when_no_connected_device` | bool | `false` | Hide the widget when no Bluetooth device is connected. | ```toml diff --git a/src/shell/bar/widgets/bluetooth_widget_definition.cpp b/src/shell/bar/widgets/bluetooth_widget_definition.cpp index e41613b00f..adb6f65736 100644 --- a/src/shell/bar/widgets/bluetooth_widget_definition.cpp +++ b/src/shell/bar/widgets/bluetooth_widget_definition.cpp @@ -1,5 +1,17 @@ #include "shell/bar/widgets/bluetooth_widget_definition.h" +namespace { + + // A powered-off adapter has no connected device, so hiding on "no connected device" + // already covers the adapter-off case and makes this toggle inert. + settings::WidgetSettingVisibility connectedDeviceFilterOff() { + settings::WidgetSettingVisibility visibility; + visibility.all = {{"hide_when_no_connected_device", {"false"}}}; + return visibility; + } + +} // namespace + const noctalia::bar::WidgetDefinition& bluetoothWidgetDefinition() { using noctalia::bar::field; using Options = BluetoothWidget::Options; @@ -12,6 +24,10 @@ const noctalia::bar::WidgetDefinition& bluetoothWidget }), field<&Options::hideWhenAdapterOff>({ .key = "hide_when_adapter_off", + .presentation = + settings::WidgetSettingPresentation{ + .visibleWhen = connectedDeviceFilterOff(), + }, }), field<&Options::hideWhenNoConnectedDevice>({ .key = "hide_when_no_connected_device",