diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index 869bb8feb..6844ff330 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -387,6 +387,22 @@ const gchar desktop_key_match_category[N_DESKTOP_KEYS] = { [DESKTOP_KEY_Comment] = 6 }; +/* Common prefix commands to ignore from Exec= lines */ +const char * const exec_key_match_blacklist[] = { + "bash", + "env", + "flatpak", + "gjs", + "pkexec", + "python", + "python2", + "python3", + "sh", + "wine", + "wine64", + NULL +}; + static gchar * desktop_key_get_name (guint key_id) { @@ -1089,6 +1105,10 @@ desktop_file_dir_unindexed_setup_search (DesktopFileDir *dir) /* Skip the pathname, if any */ if ((slash = strrchr (raw, '/'))) value = slash + 1; + + /* Don't match on blacklisted binaries like interpreters */ + if (g_strv_contains (exec_key_match_blacklist, value)) + value = NULL; } if (value) diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c index 738b78cef..d425eb9e5 100644 --- a/gio/tests/desktop-app-info.c +++ b/gio/tests/desktop-app-info.c @@ -667,6 +667,11 @@ test_search (void) assert_search ("image viewer", "", FALSE, TRUE, NULL, NULL); assert_search ("image viewer", "", TRUE, TRUE, NULL, NULL); + /* There're flatpak apps installed as well - they should *not* match + * the "flatpak" command in the Exec= line though. + */ + assert_search ("flatpak", "", TRUE, FALSE, NULL, NULL); + /* Obvious multi-word search */ assert_search ("gno hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL);