Added a 'Connected' indicator if one or more bluetooth devices are connected.

This commit is contained in:
Jas Singh
2024-07-27 02:41:57 -07:00
parent d8e58546ad
commit 40a24b3425
4 changed files with 302 additions and 285 deletions

View File

@@ -10,13 +10,19 @@ const Bluetooth = () => {
});
const btText = Widget.Label({
label: Utils.merge([bluetooth.bind("enabled"), options.bar.bluetooth.label.bind("value")], (btEnabled, showLabel) => {
if (showLabel) {
return btEnabled ? " On" : " Off"
}
return "";
label: Utils.merge([
bluetooth.bind("enabled"),
bluetooth.bind("connected_devices"),
options.bar.bluetooth.label.bind("value")],
(btEnabled, btDevices, showLabel) => {
if (showLabel) {
return btEnabled && btDevices.length ? ` Connected (${btDevices.length})`
: btEnabled ? " On"
: " Off"
}
return "";
}),
}),
class_name: "bar-bt_label",
});

View File

@@ -14,7 +14,7 @@ const devices = (bluetooth: Bluetooth, self: Box<any, any>) => {
hpack: "center",
children: [
Widget.Label({
class_name: "dim",
class_name: "bluetooth-disabled dim",
hexpand: true,
label: "Bluetooth is disabled",
}),