Skip to content

Commit

Permalink
notifications: Try to guess app id if getting from hints fails
Browse files Browse the repository at this point in the history
The notification spec states that the `desktop-entry` hint should be the prefix of the Desktop Application Info file. However, because of the push to have fully-qualified app ID's, some applications now have a mismatch between the ID and the desktop file, meaning the hint cannot be used for that application.

In cases where the hint fails, try to guess the ID using the application's name given to us from DBus.

It seems to fix #477.

Signed-off-by: Evan Maddock <maddock.evan@vivaldi.net>
  • Loading branch information
EbonJaeger committed Oct 16, 2023
1 parent bc90025 commit 627710d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/lib/notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,27 @@
category = variant.get_string();
}

// Set the application ID and app info
// Try to set the application ID and app info
if ((variant = hints.lookup("desktop-entry")) != null && variant.is_of_type(VariantType.STRING)) {
app_id = variant.get_string();
app_id.replace(".desktop", "");
app_info = new DesktopAppInfo("%s.desktop".printf(app_id));
}

// Because following specs is a lost art, sometimes the desktop-entry
// value does not correspond to the desktop file. So, try to best-guess
// the desktop id instead.
if (app_info == null) {
app_id = app_name.replace(" ", "-").down();
app_info = new DesktopAppInfo("%s.desktop".printf(app_id));
}

if (app_info != null) app_name = app_info.get_string("Name") ?? app_name;
// Make sure we have the best app name
if (app_info != null) {
app_name = app_info.get_string("Name") ?? app_name;
}

// Try to get the application's image
app_image = get_appinfo_image(Gtk.IconSize.DND, app_id.down());

bool image_found = false;
Expand Down Expand Up @@ -272,4 +284,4 @@
return null;
}
}
}
}

0 comments on commit 627710d

Please sign in to comment.