nixos-configs/config/ags/js/bar/notif-button.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

const { Box, Label, Icon } = ags.Widget;
const { toggleWindow } = ags.App;
const { Notifications } = ags.Service;
2023-09-05 15:10:25 -04:00
2023-09-11 19:57:21 -04:00
import { Separator } from '../misc/separator.js';
import { EventBox } from '../misc/cursorbox.js';
export const NotifButton = EventBox({
className: 'toggle-off',
onPrimaryClickRelease: () => toggleWindow('notification-center'),
connections: [
[ags.App, (box, windowName, visible) => {
if (windowName == 'notification-center') {
NotifButton.toggleClassName('toggle-on', visible);
}
}],
],
2023-09-05 15:10:25 -04:00
child: Box({
className: 'notif-panel',
vertical: false,
children: [
Separator(28),
Icon({
connections: [
[Notifications, icon => {
2023-09-11 16:25:57 -04:00
// TODO: add no notifs vs notifs
icon.icon = Notifications.dnd
? 'notifications-disabled-symbolic'
: 'preferences-system-notifications-symbolic';
}],
],
}),
Separator(8),
Label({
connections: [
[Notifications, label => {
label.label = String(Notifications.notifications.length);
}],
],
}),
],
2023-09-05 15:10:25 -04:00
}),
});