Freedesktop, GNOME, and KDE notes

From Helpful
Jump to: navigation, search
This hasn't been updated for a while, so could be outdated (particularly if it's about something that evolves constantly, such as software).
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

Mostly "stuff that adheres to freedesktop, and some details to getting it to work in practice"


On skel and xdg

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

A bunch of this sits in /etc/xdg, a freedesktop.org standardization e.g.


If, in lieu of cleanup, you want to know exactly what packages these contents come from, try:

find /etc/skel /etc/xdg | xargs apt-file search


https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html


.desktop files

Example content of a .desktop file to launch an application:

[Desktop Entry]
Version=1.0
Name=ProgramName
Comment=What it does
Exec=/path/to/exec.sh
Icon=/path/to/icon.png
Terminal=false
Type=Application
Categories=Utility

Notes:

  • Exec path may be relative if it's in the PATH
  • Icon path may be
    • absolute path, OR a relative and extensionless name referring to something in /usr/share/pixmaps (more specifically, see the resolution mentioned in [4])
    • image format: xpm, png, svg. The last may not be supported by everything(?) (verify)
  • Version refers to version of the .desktop standard. Current version is 1.0. This key is not required.
  • it seems GNOME only accepts it as an application selectable under e.g. "open with other application" if you adhere to the file naming (verify)


See Also


Findable by the launcher

If you want the launcher to offer these when you search for them, put .desktop files in:

For all users:
/usr/share/applications/
For individual users:
/home/username/.local/share/applications/

It seems it accepts subdirectories and symlinks, which can make finer-grained sharing of .desktop files easier.


Icons on your actual desktop

Put a copy or symlink in ~/Desktop and ensure it is executable (only then will it be parsed, executable, and show the right icon).


icons in the GNOME favorites/dock

These are the favorites in your dock / launcher


Once you can find them, you can add them with the mouse.

If you, as an admin, want to alter them mechanically, this varies with the version of GNOME, and with whether you want to do it via an API or try to get it right on the command line.

TODO: figure out more, post script

MIME and such

MIME type detection

In practical terms it's approximately

  • writing a file like
    /usr/share/mime/packages/mymime.xml
  • running
    update-mime-database /usr/share/mime
    .


That file (see specs here) would look something like:

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="image/x-stack">
    <sub-class-of type="image/raw"/>
    <glob pattern="*.img"/>
    <magic priority="50">
      <match type="little32" offset="0" value="0"/>
    </magic>
    <generic-icon name="image-x-generic">
    <comment>raw image stack</comment>
  </mime-type>
</mime-info>

match elements have:

  • type string, host16, host32, big16, big32, little16, little32 or byte.
  • offset - single byte offset, or from:to range (inclusive)
  • value - thing to check, in the format relevant for the type
  • mask (optional) - AND the value

Logic:

  • OR rules by putting them at the same level
  • AND rules by nesting them

Priority - lets you deal with more and less specific variants. For example, modern office documents are zip files, meaning their matching should have a higher priority than zip archives in general.

(globs can have weight)


While debugging you probably want to:

xdg-mime query filetype filename

Application associations

See also:

Thumbnailer

A thumbnailer is a program that takes:

  • a target size
  • a filename or URL-style path
  • an output file

...and writes a PNG image to that output file.


They are hooked in by adding a file like
/usr/share/thumbnailers/mymime.thumbnailer
with:
[Thumbnailer Entry]
MimeType=application/x-mymime;
Exec=my-thumbnailer %s %f %o

...where

  • those parameters
 %s is the size (typically 128 or 256), though the thumbnailer will size down if yours doesn't
 %f is a file path
 %u is an URL-style path (usually you choose either %f or %u)
 %o is the output file to write to (probably a random filename in /tmp)


There's a bunch of footnotes to URLs, TryExec, etc.

If you are debugging a thumbnailer, you may wish to empty earlier attempts, including:

  • Cached thumbnailes under
    ~/.cache/thumbnails/
  • Cached failures in
    ~/.cache/thumbnails/fail/gnome-thumbnail-factory/

See also:



If it's not working

Is it on a network filesystem?

Then if we're set to "local-only" (see preferences, or gsettings get org.gnome.nautilus.preferences show-image-thumbnails) it intentionally isn't generating these, to not load the network.

That's the sanely minimal option, you can enable that if you know it's not an issue on your network.



Is it generating failed images, try to check that it's getting run at all.

There may be errors early in your program startup - but there are also reason it's not getting run at all

https://bugs.funtoo.org/secure/attachment/16930/debug.html

https://unix.stackexchange.com/questions/260162/how-to-track-newly-created-processes-in-linux