💥 ags(notifications): also check AstalNotifd.Notification.appIcon for image path
this commit fixes issues with hyprshot screenshot notification and markup issues with the new truncating method
This commit is contained in:
@@ -15,6 +15,21 @@ export function getUrgencyString(notif: AstalNotifd.Notification) {
|
|||||||
return "normal";
|
return "normal";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNotificationImage(notif: AstalNotifd.Notification|HistoryNotification): (string|undefined) {
|
||||||
|
const img = notif.image ?? notif.appIcon;
|
||||||
|
if(!img) return undefined;
|
||||||
|
|
||||||
|
if(!img.includes('/')) return undefined;
|
||||||
|
|
||||||
|
if(img.startsWith('/'))
|
||||||
|
return `file://${img}`;
|
||||||
|
|
||||||
|
if(img.startsWith('~') || img.startsWith("file://~"))
|
||||||
|
return `file://${GLib.get_home_dir()}/${img.replace(/^(file\:\/\/|\~|file\:\/\/~)/g, "")}`;
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
export function NotificationWidget(notification: AstalNotifd.Notification|number|HistoryNotification,
|
export function NotificationWidget(notification: AstalNotifd.Notification|number|HistoryNotification,
|
||||||
onClose?: (notif: AstalNotifd.Notification|HistoryNotification) => void,
|
onClose?: (notif: AstalNotifd.Notification|HistoryNotification) => void,
|
||||||
showTime?: boolean /* It's showTime :speaking_head: :boom: :bangbang: */): Gtk.Widget {
|
showTime?: boolean /* It's showTime :speaking_head: :boom: :bangbang: */): Gtk.Widget {
|
||||||
@@ -23,9 +38,12 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
|
|||||||
AstalNotifd.get_default().get_notification(notification)
|
AstalNotifd.get_default().get_notification(notification)
|
||||||
: notification;
|
: notification;
|
||||||
|
|
||||||
const body: string = notification.body.split(' ').map(strPart =>
|
const body: string = notification.body.split(' ').map(strPart => {
|
||||||
strPart.length >= 25 ? `${strPart.substring(0, 22)}...`
|
if(/^\<.*\>.*\<.*\>$/.test(strPart)) return strPart;
|
||||||
: strPart).join(' ');
|
|
||||||
|
return strPart.length >= 25 ? `${strPart.substring(0, 22)}...`
|
||||||
|
: strPart
|
||||||
|
}).join(' ');
|
||||||
|
|
||||||
return new Widget.EventBox({
|
return new Widget.EventBox({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
@@ -100,8 +118,12 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
|
|||||||
children: [
|
children: [
|
||||||
new Widget.Box({
|
new Widget.Box({
|
||||||
className: "image",
|
className: "image",
|
||||||
visible: Boolean(notification.image),
|
setup: (box) => {
|
||||||
css: `box.image { background-image: url('${notification.image}'); }`
|
const img = getNotificationImage(notification);
|
||||||
|
|
||||||
|
box.set_visible(Boolean(img));
|
||||||
|
img && box.set_css(`background-image: image(url("${img}"))`);
|
||||||
|
}
|
||||||
} as Widget.BoxProps),
|
} as Widget.BoxProps),
|
||||||
new Widget.Box({
|
new Widget.Box({
|
||||||
className: "text",
|
className: "text",
|
||||||
|
|||||||
Reference in New Issue
Block a user