2023-12-18 18:00:30 -05:00
|
|
|
// @ts-expect-error
|
2023-12-05 11:35:40 -05:00
|
|
|
import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js';
|
|
|
|
|
|
|
|
import { Label, Box, EventBox, Icon, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
|
|
|
|
import Separator from '../../misc/separator.js';
|
|
|
|
|
|
|
|
const SPACING = 5;
|
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-12-05 11:35:40 -05:00
|
|
|
export default () => {
|
2023-12-18 18:00:30 -05:00
|
|
|
const icon = Icon().hook(Bluetooth, (self) => {
|
|
|
|
if (Bluetooth.enabled) {
|
|
|
|
self.icon = Bluetooth.connectedDevices[0] ?
|
|
|
|
Bluetooth.connectedDevices[0].iconName :
|
|
|
|
'bluetooth-active-symbolic';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
self.icon = 'bluetooth-disabled-symbolic';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const hoverRevLabel = Revealer({
|
2023-12-05 11:35:40 -05:00
|
|
|
transition: 'slide_right',
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-12-05 11:35:40 -05:00
|
|
|
child: Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-12-05 11:35:40 -05:00
|
|
|
children: [
|
|
|
|
Separator(SPACING),
|
2023-12-18 18:00:30 -05:00
|
|
|
|
|
|
|
Label().hook(Bluetooth, (self) => {
|
|
|
|
self.label = Bluetooth.connectedDevices[0] ?
|
|
|
|
`${Bluetooth.connectedDevices[0]}` :
|
|
|
|
'Disconnected';
|
|
|
|
}, 'notify::connected-devices'),
|
2023-12-05 11:35:40 -05:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
const widget = EventBox({
|
2023-12-18 18:00:30 -05:00
|
|
|
on_hover: () => {
|
|
|
|
hoverRevLabel.reveal_child = true;
|
2023-12-05 11:35:40 -05:00
|
|
|
},
|
2023-12-18 18:00:30 -05:00
|
|
|
on_hover_lost: () => {
|
|
|
|
hoverRevLabel.reveal_child = false;
|
2023-12-05 11:35:40 -05:00
|
|
|
},
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-12-05 11:35:40 -05:00
|
|
|
child: Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'bluetooth',
|
2023-12-05 11:35:40 -05:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
children: [
|
|
|
|
icon,
|
|
|
|
hoverRevLabel,
|
2023-12-05 11:35:40 -05:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
};
|