From ec623a2371181004e5e6b166ddcd7b4704dbcbbe Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Sat, 12 Apr 2025 16:42:21 -0300 Subject: [PATCH] :sparkles: ags(notifications): more advanced notification body truncating --- ags/widget/Notification.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ags/widget/Notification.ts b/ags/widget/Notification.ts index 4becdaa..3b776be 100644 --- a/ags/widget/Notification.ts +++ b/ags/widget/Notification.ts @@ -23,6 +23,10 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number AstalNotifd.get_default().get_notification(notification) : notification; + const body: string = notification.body.split(' ').map(strPart => + strPart.length >= 25 ? `${strPart.substring(0, 22)}...` + : strPart).join(' '); + return new Widget.EventBox({ onClick: () => { if(notification instanceof AstalNotifd.Notification) { @@ -118,7 +122,7 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number xalign: 0, truncate: false, wrap: true, - label: notification.body.replace(/\&/g, "&") + label: body.replace(/\&/g, "&") } as Widget.LabelProps) ] } as Widget.BoxProps)