bar: show bluetooth battery

This commit is contained in:
end-4
2024-03-08 22:32:55 +07:00
parent 1f6b7b42d5
commit 7f3bf94421
2 changed files with 40 additions and 1 deletions
@@ -84,6 +84,31 @@ export const BluetoothIndicator = () => Widget.Stack({
,
});
const BluetoothDevices = () => Widget.Box({
className: 'spacing-h-10',
setup: self => self.hook(Bluetooth, self => {
self.children = Bluetooth.connected_devices.map((device) => {
return Widget.Box({
className: 'bar-bluetooth-device spacing-h-5',
vpack: 'center',
tooltipText: device.name,
children: [
Widget.Icon(`${device.iconName}-symbolic`),
(device.batteryPercentage ? Widget.Label({
className: 'txt-smallie',
label: `${device.batteryPercentage}`,
setup: (self) => {
self.hook(device, (self) => {
self.label = `${device.batteryPercentage}`;
}, 'notify::batteryPercentage')
}
}) : null),
]
});
});
self.visible = Bluetooth.connected_devices.length > 0;
}, 'notify::connected-devices'),
})
const NetworkWiredIndicator = () => Widget.Stack({
transition: 'slide_up_down',
@@ -247,7 +272,10 @@ export const StatusIcons = (props = {}) => Widget.Box({
optionalKeyboardLayoutInstance,
NotificationIndicator(),
NetworkIndicator(),
BluetoothIndicator(),
Widget.Box({
className: 'spacing-h-5',
children: [BluetoothIndicator(), BluetoothDevices()]
})
]
})
});
+11
View File
@@ -350,4 +350,15 @@ $bar_subgroup_bg: $surfaceVariant;
.bar-util-btn:active {
background-color: mix($bar_subgroup_bg, $onSurfaceVariant, 80%);
}
.bar-bluetooth-device {
@include full-rounding;
@include element_decel;
min-height: 1.032rem;
min-width: 1.032rem;
font-size: 1.032rem;
background-color: $surface;
color: $onSurface;
padding: 0.205rem 0.341rem;
}