bar: fix bluetooth tooltip
This commit is contained in:
parent
0592075b4e
commit
434efd3270
1 changed files with 7 additions and 4 deletions
|
|
@ -309,18 +309,21 @@ const Bluetooth = () => (
|
||||||
execAsync("uwsm app -- blueman-manager").catch(console.error);
|
execAsync("uwsm app -- blueman-manager").catch(console.error);
|
||||||
}}
|
}}
|
||||||
setup={self => {
|
setup={self => {
|
||||||
|
const bluetooth = AstalBluetooth.get_default();
|
||||||
const tooltipText = Variable("");
|
const tooltipText = Variable("");
|
||||||
const update = () => {
|
const update = () => {
|
||||||
const devices = AstalBluetooth.get_default()
|
const devices = bluetooth.get_devices().filter(d => d.connected);
|
||||||
.get_devices()
|
|
||||||
.filter(d => d.connected);
|
|
||||||
tooltipText.set(
|
tooltipText.set(
|
||||||
devices.length > 0
|
devices.length > 0
|
||||||
? `Connected devices: ${devices.map(d => d.alias).join(", ")}`
|
? `Connected devices: ${devices.map(d => d.alias).join(", ")}`
|
||||||
: "No connected devices"
|
: "No connected devices"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
self.hook(AstalBluetooth.get_default(), "notify", update); // TODO: fix not updating
|
bluetooth.get_devices().forEach(d => self.hook(d, "notify::connected", update));
|
||||||
|
self.hook(bluetooth, "device-added", (_, device) => {
|
||||||
|
self.hook(device, "notify::connected", update);
|
||||||
|
update();
|
||||||
|
});
|
||||||
update();
|
update();
|
||||||
setupCustomTooltip(self, bind(tooltipText));
|
setupCustomTooltip(self, bind(tooltipText));
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue