mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
Notification: add -i support
This commit is contained in:
@@ -118,12 +118,13 @@ Singleton {
|
||||
|
||||
// Function to add notification to model
|
||||
function addNotification(notification) {
|
||||
const resolvedImage = resolveNotificationImage(notification)
|
||||
notificationModel.insert(0, {
|
||||
"rawNotification": notification,
|
||||
"summary": notification.summary,
|
||||
"body": notification.body,
|
||||
"appName": notification.appName,
|
||||
"image": notification.image,
|
||||
"image": resolvedImage,
|
||||
"appIcon": notification.appIcon,
|
||||
"urgency": notification.urgency,
|
||||
"timestamp": new Date()
|
||||
@@ -139,6 +140,40 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve an image path for a notification, supporting icon names and absolute paths
|
||||
function resolveNotificationImage(notification) {
|
||||
try {
|
||||
// If an explicit image is already provided, prefer it
|
||||
if (notification && notification.image && notification.image !== "") {
|
||||
return notification.image
|
||||
}
|
||||
|
||||
// Fallback to appIcon which may be a name or a path (notify-send -i)
|
||||
const icon = notification ? (notification.appIcon || "") : ""
|
||||
if (!icon)
|
||||
return ""
|
||||
|
||||
// Accept absolute file paths or file URLs directly
|
||||
if (icon.startsWith("/")) {
|
||||
return icon
|
||||
}
|
||||
if (icon.startsWith("file://")) {
|
||||
// Strip the scheme for QML image source compatibility
|
||||
return icon.substring("file://".length)
|
||||
}
|
||||
|
||||
// Resolve themed icon names to absolute paths
|
||||
try {
|
||||
const p = Icons.iconFromName(icon, "")
|
||||
return p || ""
|
||||
} catch (e2) {
|
||||
return ""
|
||||
}
|
||||
} catch (e) {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// Add a simplified copy into persistent history
|
||||
function addToHistory(notification) {
|
||||
historyModel.insert(0, {
|
||||
|
||||
Reference in New Issue
Block a user