Thursday, May 2, 2024
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 2702  / 3 Years ago, sun, october 10, 2021, 4:50:46

I know that if you want to add a .desktop entry it must be added in /usr/share/applications, however, what I want is to add an extra folder where it can host .desktop files.


If I run update-desktop-database you can see that programs like snapd or flatpak create their own directories where they host their .desktop


The databases in [/usr/share/ubuntu/applications, /home/cactus/.local/share/flatpak/exports/share/applications, /var/lib/flatpak/exports/share/applications, /usr/local/share/applications, /usr/share/applications, /var/lib/snapd/desktop/applications] could not be updated.

My idea is to add a folder /opt/applications where I can save .desktop of my self-compiled applications.


More From » command-line

 Answers
5

According to GNOME Desktop System Administration Guide Customizing Menus : Desktop Entry Files



Desktop entry files must reside in the $XDG_DATA_DIRS/applications
directory and must have a .desktop file extension. If $XDG_DATA_DIRS 1
is not set, then the default path is /usr/share is used. This also
implies that user specific desktop entries may be located at
$XDG_DATA_HOME/applications which is searched first. If $XDG_DATA_HOME
is not set, then the default path ~/.local/share is used. Desktop
entries are collected from all directories in the $XDG_DATA_DIRS
environment variable. Directories which appear first in $XDG_DATA_DIRS
are given precedence when there are several .desktop files with the
same name.


1 $XDG_DATA_DIRS is the environment variable defined in the XDG base directory specification.



So if $XDG_DATA_HOME does not say otherwise, you can place per-user .desktop files in ~/.local/share/applications. If you want a system-wide custom location, you should be able to add it to $XDG_DATA_DIRS ex.


XDG_DATA_DIRS=/opt:$XDG_DATA_DIRS

See also XDG Base Directory Specification


[#1338] Sunday, October 10, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tionavocad

Total Points: 189
Total Questions: 101
Total Answers: 118

Location: Liechtenstein
Member since Wed, Dec 8, 2021
2 Years ago
tionavocad questions
Tue, May 23, 23, 00:07, 1 Year ago
Tue, Jan 17, 23, 20:38, 1 Year ago
Tue, Jun 7, 22, 08:50, 2 Years ago
;