Merge branch 'retrozinndev:ryo' into ryo

This commit is contained in:
Mephisto
2025-06-11 21:14:54 +03:00
committed by GitHub
9 changed files with 84 additions and 39 deletions
+14 -16
View File
@@ -4,19 +4,23 @@ import { Separator } from "./Separator";
import { HistoryNotification, Notifications } from "../scripts/notifications";
import { GLib } from "astal";
import { getAppIcon } from "../scripts/apps";
import Pango from "gi://Pango";
function getNotificationImage(notif: AstalNotifd.Notification|HistoryNotification): (string|undefined) {
const img = notif.image ?? notif.appIcon;
if(!img) return undefined;
const img = notif.image || notif.appIcon;
if(!img.includes('/')) return undefined;
if(!img || !img.includes('/'))
return undefined;
if(img.startsWith('/'))
return `file://${img}`;
switch(true) {
case /^[/]/.test(img):
return `file://${img}`;
if(img.startsWith('~') || img.startsWith("file://~"))
return `file://${GLib.get_home_dir()}/${img.replace(/^(file\:\/\/|\~|file\:\/\/~)/g, "")}`;
case /^[~]/.test(img):
case /^file:\/\/[~]/i.test(img):
return `file://${GLib.get_home_dir()}/${img.replace(/^(file\:\/\/|[~]|file\:\/\[~])/i, "")}`;
}
return img;
}
@@ -30,14 +34,6 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
AstalNotifd.get_default().get_notification(notification)
: notification;
const body: string = notification.body.split(' ').map(strPart => {
if(/^\<(.*)\>/.test(strPart) || /<\/(.*)\>$/.test(strPart))
return strPart;
return strPart.length >= 25 ? `${strPart.substring(0, 22)}...`
: strPart
}).join(' ');
return new Widget.EventBox({
onClick: () => {
if(notification instanceof AstalNotifd.Notification) {
@@ -139,7 +135,9 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
xalign: 0,
truncate: false,
wrap: true,
label: body.replace(/\&/g, "&amp;")
singleLineMode: false,
wrapMode: Pango.WrapMode.WORD_CHAR,
label: notification.body.replace(/&/g, "&amp;")
} as Widget.LabelProps)
]
} as Widget.BoxProps)