Applications: overrides in .local/share/applications not working correctly
peppidesu opened this issue · comments
How to reproduce
- Have a
.desktop
file in/usr/share/applications
- Have a equally named
.desktop
file in~/.local/share/applications/
with one of the following:
- different
Name
field - different
Icon
field
- Open anyrun and search for the application
Expected behavior
Either the name or icon (whichever was changed) should be the one specified in the user override. The global result should not be displayed.
Actual behavior
Both the user-specified and the globally-specified entries appear in the results
How to fix
From the Desktop Entry Specification:
Each desktop entry representing an application is identified by its desktop file ID, which is based on its filename.
To determine the ID of a desktop file, make its full path relative to the $XDG_DATA_DIRS component in which the desktop file is installed, remove the "applications/" prefix, and turn '/' into '-'.
For example /usr/share/applications/foo/bar.desktop has the desktop file ID foo-bar.desktop.
If multiple files have the same desktop file ID, the first one in the $XDG_DATA_DIRS precedence order is used.
For example, if $XDG_DATA_DIRS contains the default paths /usr/local/share:/usr/share, then /usr/local/share/applications/org.foo.bar.desktop and /usr/share/applications/org.foo.bar.desktop both have the same desktop file ID org.foo.bar.desktop, but only the first one will be used.
If both foo-bar.desktop and foo/bar.desktop exist, it is undefined which is selected.
Currently, only sections with the same "Name" and "Icon" fields are overridden. This is because the key used in the hash-maps in scrubber.rs/scrubber()
is "{Name}{Icon}". Thus, the problem can be easily fixed as follows:
- Instead of merging hashsets containing
DesktopEntry
, merge them before the conversion and make them of typeHashSet<String, DirEntry>
- Have the key of these hashsets be the entry ID as described by the specification