enkore / j4-dmenu-desktop

A fast desktop menu
GNU General Public License v3.0
673 stars 69 forks source link

Fix ordering of defaults for unset/empty XDG_DATA_DIRS #171

Closed joanbm closed 1 month ago

joanbm commented 1 month ago

Administrator-owned .desktop files in /usr/local/share/applications/ should be able to override system files in /usr/share/applications/, if no XDG_DATA_DIRS is given. However, get_search_paths returned them in the opposite order, so that system .desktop files took precedence.

This is confirmed by the XDG Base Directory Specification:

$XDG_DATA_DIRS defines the preference-ordered set of base directories If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.

Use the correct default so administrator-owned files take precedence.

joanbm commented 1 month ago

Note that this fixes somewhat of a regression:

In r2.18 the default for XDG_DATA_DIRS was the same, but it did also reverse the directories when adding them to the search path which cancelled out the problem. So, in r2.18 the order was correct when XDG_DATA_DIRS was empty or unset, but incorrect when XDG_DATA_DIRS was explicitly specified.

For r3.0+ there were a lot of refactors which removed the calls to reverse the directories. So, in r3.0+ the order is incorrect when XDG_DATA_DIRS is empty or unset, but correct when XDG_DATA_DIRS is explicitly specified. And the only thing that was left to fix is to use the correct default for XDG_DATA_DIRS according to the spec.