Add timestamp to notifications and add styling to menu button

This commit is contained in:
Jas Singh
2024-07-02 23:58:49 -07:00
parent 5846470441
commit 2a0be05a2b
10 changed files with 159 additions and 132 deletions

View File

@@ -27,7 +27,7 @@ const Left = (monitor, wsMap) => {
class_name: "box-left",
hpack: "start",
spacing: 5,
children: [Menu(), BarItemBox(Workspaces(monitor, wsMap, 10)), BarItemBox(ClientTitle())],
children: [BarItemBox(Menu()), BarItemBox(Workspaces(monitor, wsMap, 10)), BarItemBox(ClientTitle())],
});
};
@@ -64,7 +64,7 @@ const LeftAlt = (monitor, wsMap) => {
class_name: "box-left",
hpack: "start",
spacing: 5,
children: [Menu(), BarItemBox(Workspaces(monitor, wsMap)), BarItemBox(ClientTitle())],
children: [BarItemBox(Menu()), BarItemBox(Workspaces(monitor, wsMap)), BarItemBox(ClientTitle())],
});
};
@@ -74,7 +74,6 @@ const CenterAlt = () => {
spacing: 5,
children: [
BarItemBox(Media()),
// BarItemBox(Notification())
],
});
};

View File

@@ -1,13 +1,18 @@
import { exec } from "resource:///com/github/Aylur/ags/utils.js";
export const Menu = () => {
return Widget.Box({
child: Widget.Button({
on_primary_click: () => exec('/home/jaskir/.config/hypr/scripts/rofi.sh'),
const Menu = () => {
return {
component: Widget.Box({
child: Widget.Label({
class_name: "bar-menu_label",
label: "󰣇",
}),
}),
});
isVisible: true,
props: {
on_primary_click: () => exec("/home/jaskir/.config/hypr/scripts/rofi.sh"),
},
};
};
export { Menu };

View File

@@ -1,9 +1,11 @@
import PopupWindow from "../PopupWindow.js";
const notifs = await Service.import("notifications");
import icons from "../../icons/index.js";
import GLib from "gi://GLib";
export default () => {
notifs.popupTimeout = 5000;
const time = (time, format = "%I:%M %p") =>
GLib.DateTime.new_from_unix_local(time).format(format);
return PopupWindow({
name: "notificationsmenu",
@@ -141,9 +143,11 @@ export default () => {
];
}
return [Widget.Box({
class_name: "spacer"
})];
return [
Widget.Box({
class_name: "spacer",
}),
];
};
const NotificationIcon = ({
@@ -219,6 +223,12 @@ export default () => {
vertical: false,
hexpand: true,
children: [
Widget.Box({
class_name:
"notification-card-header menu",
hpack: "start",
children: [NotificationIcon(notif)],
}),
Widget.Box({
class_name:
"notification-card-header menu",
@@ -232,8 +242,8 @@ export default () => {
hexpand: true,
vexpand: true,
max_width_chars: !notifHasImg(notif)
? 27
: 20,
? 34
: 26,
truncate: "end",
wrap: true,
label: notif["summary"],
@@ -243,9 +253,14 @@ export default () => {
Widget.Box({
class_name:
"notification-card-header menu",
hexpand: true,
hpack: "end",
children: [NotificationIcon(notif)],
vpack: "start",
hexpand: true,
child: Widget.Label({
vexpand: true,
class_name: "notification-time",
label: time(notif.time),
}),
}),
],
}),

View File

@@ -1,9 +1,13 @@
const notifs = await Service.import("notifications");
import GLib from "gi://GLib";
import icons from "../icons/index.js";
export default () => {
notifs.popupTimeout = 7000;
const time = (time, format = "%I:%M %p") =>
GLib.DateTime.new_from_unix_local(time).format(format);
return Widget.Window({
name: "notifications-window",
class_name: "notifications-window",
@@ -122,9 +126,15 @@ export default () => {
vertical: false,
hexpand: true,
children: [
Widget.Box({
class_name: "notification-card-header",
hpack: "start",
children: [NotificationIcon(notif)],
}),
Widget.Box({
class_name: "notification-card-header",
hexpand: true,
hpack: "start",
vpack: "start",
children: [
Widget.Label({
@@ -132,7 +142,7 @@ export default () => {
hpack: "start",
hexpand: true,
vexpand: true,
max_width_chars: !notifHasImg(notif) ? 27 : 20,
max_width_chars: !notifHasImg(notif) ? 30 : 23,
truncate: "end",
wrap: true,
label: notif["summary"],
@@ -140,10 +150,15 @@ export default () => {
],
}),
Widget.Box({
class_name: "notification-card-header",
hexpand: true,
class_name: "notification-card-header menu",
hpack: "end",
children: [NotificationIcon(notif)],
vpack: "start",
hexpand: true,
child: Widget.Label({
vexpand: true,
class_name: "notification-time",
label: time(notif.time),
}),
}),
],
}),