Updated and completed the notifications and bluetooth module.
This commit is contained in:
@@ -21,8 +21,6 @@ const Volume = () => {
|
||||
},
|
||||
);
|
||||
|
||||
console.log(icon);
|
||||
|
||||
return icon.as((i) => icons[i]);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@ const audio = await Service.import("audio");
|
||||
import DropdownMenu from "../DropdownMenu.js";
|
||||
|
||||
export default () => {
|
||||
audio.connect("changed", val => {
|
||||
// console.log(JSON.stringify(val, null, 2));
|
||||
})
|
||||
const renderPlaybacks = (playbackDevices) => {
|
||||
return playbackDevices.map((device) => {
|
||||
if (device.description === "Dummy Output") {
|
||||
|
||||
@@ -84,17 +84,7 @@ export default () => {
|
||||
"menu-icon-button-label disconnect bluetooth",
|
||||
label: dev.connected ? "" : "",
|
||||
}),
|
||||
on_primary_click: () =>
|
||||
Utils.execAsync([
|
||||
"bash",
|
||||
"-c",
|
||||
`bluetoothctl ${dev.connected ? "disconnect" : "connect"} ${dev.address}`,
|
||||
]).catch((err) =>
|
||||
console.error(
|
||||
`bluetoothctl ${dev.connected ? "disconnect" : "connect"} ${dev.address}`,
|
||||
err,
|
||||
),
|
||||
),
|
||||
on_primary_click: () => dev.setConnection(false),
|
||||
}),
|
||||
Widget.Button({
|
||||
class_name: "menu-icon-button untrust bluetooth",
|
||||
@@ -123,7 +113,6 @@ export default () => {
|
||||
label: "",
|
||||
}),
|
||||
on_primary_click: () => {
|
||||
// dev.setConnection(false);
|
||||
Utils.execAsync([
|
||||
"bash",
|
||||
"-c",
|
||||
@@ -190,7 +179,7 @@ export default () => {
|
||||
hexpand: true,
|
||||
class_name: `menu-button bluetooth ${device}`,
|
||||
on_primary_click: () => {
|
||||
device.setConnection(true);
|
||||
device.setConnection(true);
|
||||
},
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
|
||||
@@ -6,16 +6,15 @@ export default () => {
|
||||
return Widget.Window({
|
||||
name: "notifications-window",
|
||||
class_name: "notifications-window",
|
||||
layer: "top",
|
||||
anchor: ["top", "right"],
|
||||
layer: "overlay",
|
||||
anchor: ["top","right"],
|
||||
monitor: 2,
|
||||
exclusivity: "ignore",
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
vertical: true,
|
||||
class_name: "notification-card-container",
|
||||
setup: (self) => {
|
||||
self.hook(notifs, () => {
|
||||
console.log(JSON.stringify(notifs.popups, null, 2));
|
||||
if (notifs.dnd) {
|
||||
return;
|
||||
}
|
||||
@@ -26,6 +25,7 @@ export default () => {
|
||||
Widget.Box({
|
||||
class_name: "notification-card-image-container",
|
||||
hpack: "center",
|
||||
vpack: "center",
|
||||
vexpand: false,
|
||||
child: Widget.Box({
|
||||
hpack: "center",
|
||||
@@ -40,80 +40,86 @@ export default () => {
|
||||
return [];
|
||||
};
|
||||
|
||||
return (self.children = notifs.popups.map((notif, index) => {
|
||||
return Widget.Box({
|
||||
child: Widget.Box({
|
||||
class_name: "notification-card",
|
||||
children: [
|
||||
...imageContainer(notif),
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
hpack: "end",
|
||||
class_name: "notification-card-content",
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "notification-card-header",
|
||||
const actionsContainer = (notif) => {
|
||||
if (notif.actions !== undefined && notif.actions.length > 0) {
|
||||
return [
|
||||
Widget.Box({
|
||||
class_name: "notification-card-actions",
|
||||
hpack: "start",
|
||||
children: notif.actions.map((action) => {
|
||||
return Widget.Button({
|
||||
class_name: "notification-action-buttons",
|
||||
on_primary_click: () => {
|
||||
notif.invoke(action.id);
|
||||
},
|
||||
child: Widget.Box({
|
||||
hpack: "center",
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: "notification-card-header-label",
|
||||
truncate: "end",
|
||||
wrap: true,
|
||||
label: notif["summary"],
|
||||
class_name: "notification-action-buttons-label",
|
||||
label: action.label,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "notification-card-body",
|
||||
vexpand: true,
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: "notification-card-body-label",
|
||||
useMarkup: true,
|
||||
lines: 2,
|
||||
wrap: true,
|
||||
truncate: "end",
|
||||
label: notif["body"],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
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: [
|
||||
Widget.Label({
|
||||
class_name: "notification-card-appname-label",
|
||||
truncate: "end",
|
||||
wrap: true,
|
||||
label: notif["app-name"].toUpperCase(),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
return (self.children = notifs.popups.map((notif, index) => {
|
||||
// FIX: Bottom part of notification gets cut of... need to find and fix culprit
|
||||
return Widget.Box({
|
||||
class_name: "notification-card",
|
||||
children: [
|
||||
...imageContainer(notif),
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
class_name: "notification-card-content",
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "notification-card-header",
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: "notification-card-header-label",
|
||||
truncate: "end",
|
||||
wrap: true,
|
||||
label: notif["summary"],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "notification-card-body",
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: "notification-card-body-label",
|
||||
useMarkup: true,
|
||||
lines: 2,
|
||||
wrap: true,
|
||||
maxWidthChars: 30,
|
||||
truncate: "end",
|
||||
label: notif["body"],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
...actionsContainer(notif),
|
||||
Widget.Box({
|
||||
class_name: "notification-card-appname",
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: "notification-card-appname-label",
|
||||
truncate: "end",
|
||||
wrap: true,
|
||||
label: notif["app-name"].toUpperCase(),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user