Document templates specification

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Dec 7 10:45:17 PST 2011


On Wed, 07 Dec 2011 at 18:39:10 +0100, André Gillibert wrote:
> AFAIK, Nautilus (GNOME) and Thunar (XFCE) simply uses files in
> $XDG_TEMPLATES_DIR (~/Templates by default)

I believe the point of this is to make it really easy for a user to
create new templates, by having the directory be user-visible, so they
can just Save As... into that directory and have them show up as templates
(or, conversely, delete the file if the template is no longer wanted).

Having to use a special Save As Template... (which writes into a hidden
directory that inexperienced users can't be expected to go looking for)
would mean only "native" XDG apps can create templates, and having templates
in a hidden directory by default makes it harder to get rid of unwanted
templates.

> Proposal:
> Allow XDG_TEMPLATES_DIR to contain a colon-separated list of
> directories ($XDG_DATA_HOME:$XDG_DATA_DIR by default), so that system-wide templates dir can be used.

Here's another proposal, assuming that "templates folder is visible by
default" is considered to be a feature rather than a bug:

When looking for templates, search $XDG_TEMPLATES_DIR (defaulting to
~/Templates) followed by XDG_DATA_DIRS/templates according to the basedir spec
(which means: respecting $XDG_DATA_HOME and $XDG_DATA_DIRS, but defaulting to
~/.local/share/templates and /usr/local/share/templates:/usr/share/templates
respectively).

In each of those locations, look for:

* *.desktop: it's a KDE-style complex template

* any other file: it's a GNOME-style raw file

Then eliminate duplicates (presumably by dropping identical names), giving
priority to XDG_TEMPLATES_DIR, then to XDG_DATA_HOME, then each element of
XDG_DATA_DIRS; and within each directory, giving a .desktop file higher
priority than the raw file that it references.

(KDE could look in ~/.kde4/share too, as lower priority than XDG_DATA_HOME,
to be compatible with older versions of itself.)

When saving templates, put them in $XDG_TEMPLATES_DIR, again defaulting to
~/Templates.

If you want the current-KDE-like behaviour (templates are hidden) on a
desktop implementing this proposal, you could set
XDG_TEMPLATES_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/templates" to get
them out of your face. Or any other hidden directory of your choice, but
using one that's already searched seems better than proliferation of
hidden directories.

     S


More information about the xdg mailing list