Notification: show resolved app name instead of id (possibly fixes #230)
This commit is contained in:
parent
59ef26af1c
commit
d05255c15b
2 changed files with 41 additions and 3 deletions
|
|
@ -147,7 +147,7 @@ Singleton {
|
||||||
|
|
||||||
// Inject missing default setting (metaData) from BarWidgetRegistry
|
// Inject missing default setting (metaData) from BarWidgetRegistry
|
||||||
const keys = Object.keys(BarWidgetRegistry.widgetMetadata[widget.id])
|
const keys = Object.keys(BarWidgetRegistry.widgetMetadata[widget.id])
|
||||||
for (let i=0; i<keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
const k = keys[i]
|
const k = keys[i]
|
||||||
if (k === "id" || k === "allowUserSettings") {
|
if (k === "id" || k === "allowUserSettings") {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -117,14 +117,50 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to resolve app name from notification
|
||||||
|
function resolveAppName(notification) {
|
||||||
|
try {
|
||||||
|
const appName = notification.appName || ""
|
||||||
|
|
||||||
|
// If it's already a clean name (no dots or reverse domain notation), use it
|
||||||
|
if (!appName.includes(".") || appName.length < 10) {
|
||||||
|
return appName
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find a desktop entry for this app ID
|
||||||
|
const desktopEntries = DesktopEntries.byId(appName)
|
||||||
|
if (desktopEntries && desktopEntries.length > 0) {
|
||||||
|
const entry = desktopEntries[0]
|
||||||
|
// Prefer name over genericName, fallback to original appName
|
||||||
|
return entry.name || entry.genericName || appName
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no desktop entry found, try to clean up the app ID
|
||||||
|
// Convert "org.gnome.Nautilus" to "Nautilus"
|
||||||
|
const parts = appName.split(".")
|
||||||
|
if (parts.length > 1) {
|
||||||
|
// Take the last part and capitalize it
|
||||||
|
const lastPart = parts[parts.length - 1]
|
||||||
|
return lastPart.charAt(0).toUpperCase() + lastPart.slice(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return appName
|
||||||
|
} catch (e) {
|
||||||
|
// Fallback to original app name on any error
|
||||||
|
return notification.appName || ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function to add notification to model
|
// Function to add notification to model
|
||||||
function addNotification(notification) {
|
function addNotification(notification) {
|
||||||
const resolvedImage = resolveNotificationImage(notification)
|
const resolvedImage = resolveNotificationImage(notification)
|
||||||
|
const resolvedAppName = resolveAppName(notification)
|
||||||
|
|
||||||
notificationModel.insert(0, {
|
notificationModel.insert(0, {
|
||||||
"rawNotification": notification,
|
"rawNotification": notification,
|
||||||
"summary": notification.summary,
|
"summary": notification.summary,
|
||||||
"body": notification.body,
|
"body": notification.body,
|
||||||
"appName": notification.appName,
|
"appName": resolvedAppName,
|
||||||
"image": resolvedImage,
|
"image": resolvedImage,
|
||||||
"appIcon": notification.appIcon,
|
"appIcon": notification.appIcon,
|
||||||
"urgency": notification.urgency,
|
"urgency": notification.urgency,
|
||||||
|
|
@ -177,10 +213,12 @@ Singleton {
|
||||||
|
|
||||||
// Add a simplified copy into persistent history
|
// Add a simplified copy into persistent history
|
||||||
function addToHistory(notification) {
|
function addToHistory(notification) {
|
||||||
|
const resolvedAppName = resolveAppName(notification)
|
||||||
|
|
||||||
historyModel.insert(0, {
|
historyModel.insert(0, {
|
||||||
"summary": notification.summary,
|
"summary": notification.summary,
|
||||||
"body": notification.body,
|
"body": notification.body,
|
||||||
"appName": notification.appName,
|
"appName": resolvedAppName,
|
||||||
"urgency": notification.urgency,
|
"urgency": notification.urgency,
|
||||||
"timestamp": new Date()
|
"timestamp": new Date()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue