Subdirectories in share/applications/ ?

Bastian, Waldo waldo.bastian at intel.com
Tue Jun 20 22:47:14 EEST 2006


>Hi all,
>
>I just noticed that it is allowed to have subdirectories in the
>"DATA_DIR/applications/" directory. I was quite surprised to find that
>update-desktop-database handles this by replacing the directory
>separator '/' with a dash '-' when hashing the desktop files.
>
>So when I have a "share/applications/kde/foo.desktop" this file is
>listed in "share/applications/mimeinfo.cache" as "kde-foo.desktop".

Correct, share/applications/kde/foo.desktop and
share/applications/kde-foo.desktop are equivalent and should be referred
to as "kde-foo.desktop"

>Since I am the maintainer of a perl module to find appropriate programs
>for a mimetype I would like to know the details of this behavior.
>
>I have two questions about it.
>1) Is this naming scheme in any of the XDG specifications? If not, in
>which spec does it belong - I would certainly expect it in the desktop
>entry spec since it discusses the "mimeinfo.cache" file already.

It is explained in the menu specification. See the explanation of
"Desktop File Id" in
http://standards.freedesktop.org/menu-spec/1.0/go01.html and also the
explanation of AppDir in
http://standards.freedesktop.org/menu-spec/1.0/ar01s04.html#menu-file-el
ements :

"Desktop entries in the pool of available entries are identified by
their desktop-file id (see Desktop-File Id). The desktop-file id of a
desktop entry is equal to its filename, with any path components
removed. So given a <AppDir>  /foo/bar and desktop entry
/foo/bar/Hello.desktop the desktop entry would get a desktop-file id of
Hello.desktop

If the directory contains sub-directories then these sub-directories
should be (recursively) scanned as well. The name of the subdirectory
should be added as prefix to the desktop-file id together with a dash
character ("-") So given a <AppDir> /foo/bar and desktop entry
/foo/bar/booz/Hello.desktop the desktop entry would get a desktop-file
id of booz-Hello.desktop A desktop entry /foo/bar/bo/oz/Hello.desktop
would result in a desktop-file id of bo-oz-Hello.desktop"

And

"Desktop-File Id

    The id to identify a desktop entry with. For example, if
/usr/share/applications is specified as an <AppDir>, and /opt/ude as
<LegacyDir prefix="foo-"> then /usr/share/applications/foo/bar.desktop,
/usr/share/applications/foo-bar.desktop and
/opt/ude/Settings/bar.desktop all have the same desktop-file id
foo-bar.desktop"

>2) How do I resolve a desktop file from the mimeinfo.cache file ?
>Obvious replacing dashes by '/' isn't going to work since I find things
>like "xterm-usercreated.desktop" in my ".local/share/applications/"
>directory

You will need to check for both xterm-usercreated.desktop and
xterm/usercreated.desktop

Cheers,
Waldo



More information about the xdg mailing list