Updated notifications to handle actions and added a blue dbus messenger to listen for bluetooth actions.

This commit is contained in:
Jas Singh
2024-06-19 01:53:27 -07:00
parent ca488f4fb6
commit dd13346e1b
7 changed files with 265 additions and 53 deletions

View File

@@ -122,14 +122,16 @@ export default () => {
class_name: "menu-icon-button-label delete bluetooth",
label: "󰆴",
}),
on_primary_click: () =>
on_primary_click: () => {
// dev.setConnection(false);
Utils.execAsync([
"bash",
"-c",
`bluetoothctl remove ${dev.address}`,
]).catch((err) =>
console.error("Bluetooth Remove", err),
),
);
},
}),
],
}),
@@ -188,29 +190,7 @@ export default () => {
hexpand: true,
class_name: `menu-button bluetooth ${device}`,
on_primary_click: () => {
Utils.execAsync([
"bash",
"-c",
`bluetoothctl pair ${device.address}`,
]).catch((err) => {
console.error(
`bluetoothctl pair ${device.address}`,
err,
);
setTimeout(() => {
Utils.execAsync([
"bash",
"-c",
`bluetoothctl connect ${device.address}`,
]).catch((err) =>
console.error(
`bluetoothctl connect ${device.address}`,
err,
),
);
}, 2000);
});
device.setConnection(true);
},
child: Widget.Box({
children: [
@@ -253,16 +233,6 @@ export default () => {
return Widget.Box({
vertical: true,
children: [
Widget.Box({
class_name: "menu-active-container bluetooth",
vertical: true,
// children: renderActivePlayback(),
}),
Widget.Box({
class_name: "menu-active-container bluetooth",
vertical: true,
// children: renderActiveInput(),
}),
Widget.Separator({
class_name: "menu-separator",
}),

View File

@@ -15,6 +15,7 @@ export default () => {
class_name: "notification-card-container",
setup: (self) => {
self.hook(notifs, () => {
console.log(JSON.stringify(notifs.popups, null, 2));
if (notifs.dnd) {
return;
}
@@ -25,10 +26,10 @@ export default () => {
Widget.Box({
class_name: "notification-card-image-container",
hpack: "center",
vexpand: true,
vexpand: false,
child: Widget.Box({
hpack: "center",
vexpand: true,
vexpand: false,
class_name: "notification-card-image",
css: `background-image: url("${notif.image}")`,
}),
@@ -40,13 +41,7 @@ export default () => {
};
return (self.children = notifs.popups.map((notif, index) => {
return Widget.Button({
on_primary_click: () => {
notifs.CloseNotification(notif.id);
},
on_secondary_click: () => {
notifs.CloseNotification(notif.id);
},
return Widget.Box({
child: Widget.Box({
class_name: "notification-card",
children: [
@@ -81,6 +76,29 @@ export default () => {
}),
],
}),
Widget.Box({
class_name: "notification-card-actions",
children: notif.actions.map((action) => {
return Widget.Button({
class_name: "notification-action-buttons",
on_primary_click: () => {
console.log(`clicked: ${action.id}`);
notif.invoke(action.id);
},
child: Widget.Box({
children: [
Widget.Label({
hpack: "center",
hexpand: true,
class_name:
"notification-action-buttons-label",
label: action.label,
}),
],
}),
});
}),
}),
Widget.Box({
class_name: "notification-card-appname",
children: [