Files
custum-hyprpanel/modules/notifications/index.ts
matavach 48a5bedb37 Notification monitors (#81)
* added monitor options for notifications

* added monitor options for notifications

* ..

* added changes

* Update widget/settings/pages/config/notifications/index.ts

* Added the ability for left/right anchors for notifications and updated types to reflect that.

* merge (not sure if I did this correct)

* Implemented Wallpaper Selector and Matugen's Wallpaper based auto-theming. (#73)

* Implement matugen - WIP

* Added matugen

* Add types and cleanup code

* Matugen implementation updates and added more options such as scheme and contrast.

* Code cleanup and matugen settings renamed for clarity.

* Makon maroon a primary matugen color.

* Updates to handle variations of matugen colors

* Finalizing matugen and wrapping up variations.

* Minor styling updates of the settings dialog.

* Do a swww dependency check.

* Dependency logic update

* Switch shouldn't double trigger notifications now when checking dependency.

* Logic was inverted

* Add matugen to dependency checker.

* Fixed dependency checking conditional

* Update dependency list in readme and check for matugen before doing matugen operations

* Styling fixes

* OSD Fix

* Remove unused code from wallpaper service.

* Color fixes for matugen.

* Nix updates for new dependencies

* Change default wallpaper to empty.

* Added custom notification service for startup, cleaned up code and updated readme.

* added options for bar media module (#88)

* added options for bar media module

* added reviewed changes

* cleaned up

* Made the media player more responsive and accurate. (#95)

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
2024-08-09 17:33:30 -07:00

73 lines
2.6 KiB
TypeScript

const notifs = await Service.import("notifications");
import options from "options";
import { notifHasImg } from "../menus/notifications/utils.js";
import { Image } from "./image/index.js";
import { Action } from "./actions/index.js";
import { Header } from "./header/index.js";
import { Body } from "./body/index.js";
import { CloseButton } from "./close/index.js";
import { getPosition } from "lib/utils.js";
const hyprland = await Service.import("hyprland");
const { position, timeout, cache_actions, monitor, active_monitor } = options.notifications;
const curMonitor = Variable(monitor.value);
hyprland.active.connect("changed", () => {
curMonitor.value = hyprland.active.monitor.id;
})
export default () => {
Utils.merge([timeout.bind("value"), cache_actions.bind("value")], (timeout, doCaching) => {
notifs.popupTimeout = timeout;
notifs.cacheActions = doCaching;
});
return Widget.Window({
name: "notifications-window",
class_name: "notifications-window",
monitor: Utils.merge([
curMonitor.bind("value"),
monitor.bind("value"),
active_monitor.bind("value")], (curMon, mon, activeMonitor) => {
if (activeMonitor === true) {
return curMon;
}
return mon;
}
),
layer: "overlay",
anchor: position.bind("value").as(v => getPosition(v)),
exclusivity: "ignore",
child: Widget.Box({
class_name: "notification-card-container",
vertical: true,
hexpand: true,
setup: (self) => {
self.hook(notifs, () => {
return (self.children = notifs.popups.map((notif) => {
return Widget.Box({
class_name: "notification-card",
vpack: "start",
hexpand: true,
children: [
Image(notif),
Widget.Box({
vpack: "start",
vertical: true,
hexpand: true,
class_name: `notification-card-content ${!notifHasImg(notif) ? "noimg" : ""}`,
children: [Header(notif), Body(notif), Action(notif, notifs)],
}),
CloseButton(notif, notifs),
],
});
}));
});
},
}),
});
};