Skip to content

Commit 8cc0d28

Browse files
fix(desktop_entries): respect NoDisplay precedence
Closes: pop-os/cosmic-epoch#905 `NoDisplay` allows applications or users to signal that an entry shouldn't be shown in menus. This is useful for entries that may launch an app in a certain way such as opening a specific menu or handling a MIME type. Some desktop environments use it to signal special cases. `NoDisplay` as well as `Hidden` allow user defined entries to hide apps. User defined desktop entries should override the system's applications, but the old logic continued parsing entries from all locations instead of stopping at a user override.
1 parent 6a1b8b9 commit 8cc0d28

File tree

1 file changed

+14
-6
lines changed
  • plugins/src/desktop_entries

1 file changed

+14
-6
lines changed

plugins/src/desktop_entries/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ impl<W: AsyncWrite + Unpin> App<W> {
7676
let desktop_entries = DesktopEntry::from_paths(paths, &locales)
7777
.filter_map(|de| {
7878
de.ok().and_then(|de| {
79-
if deduplicator.contains(de.appid.as_ref()) {
79+
// Treat Flatpak and system apps differently in the cache so they don't
80+
// override each other
81+
let appid = de.flatpak().unwrap_or_else(|| de.appid.as_ref());
82+
if deduplicator.contains(appid) {
8083
return None;
8184
}
85+
// Always cache already visited entries to allow overriding entries e.g. by
86+
// placing a modified copy in ~/.local/share/applications/
87+
deduplicator.insert(appid.to_owned());
8288

8389
if de.name(&self.locales).is_none() {
8490
return None;
@@ -128,12 +134,14 @@ impl<W: AsyncWrite + Unpin> App<W> {
128134
return None;
129135
}
130136
}
131-
} else {
132-
if de.no_display() {
133-
return None;
134-
}
135137
}
136-
deduplicator.insert(de.appid.to_string());
138+
// Treat `OnlyShowIn` as an override otherwise do not show if `NoDisplay` is true
139+
// Some desktop environments set `OnlyShowIn` and `NoDisplay = true` to
140+
// indicate special entries
141+
else if de.no_display() {
142+
return None;
143+
}
144+
137145
Some(de)
138146
})
139147
})

0 commit comments

Comments
 (0)