4.5 From a File to an Identifier

Given a path, a consumer finds the identifier to draw by consulting the sources below in order, and taking the first identifier that the chain provides (§4.4). A source that yields no identifier, or one the chain does not provide, is passed over and the next is consulted. If every source is passed over, the identifier is generic, which the base theme provides (§4.A).

A consumer MUST consult the sources in this order and MUST NOT skip one.

4.5.1 A governing specification #

A specification that says what a kind of file means to a desktop MAY also say what icon it has. A consumer that implements such a specification applies it first, and if it yields an identifier the chain provides, that is the icon.

Such a specification MUST yield an identifier, to be looked up under §4.4 like any other, and MUST NOT yield a picture.

4.5.2 The owner's word #

A file or directory MAY carry the extended attribute user.pgss.icon, whose value is an identifier. The attribute is the word of whoever owns the file, and is consulted second.

A consumer MUST treat a value that is not in the form of an identifier as no value. A consumer MAY treat a value ending in a NUL byte as though the NUL were absent.

Because the attribute is in the user namespace, whoever can write the file can set it, and it can be set on regular files and directories only. A file that cannot carry an attribute is drawn by the sources that follow.

4.5.3 The program's word #

A regular file that is an ELF object MAY carry a section named .pgss.icon, whose contents are an identifier, optionally followed by a NUL byte and nothing else. The section is the word of whoever built the program, and is consulted third.

A consumer finds the section by the object's section header table, by name, and takes the first section of that name. A consumer MUST NOT execute or load the object to find it, and MUST bound what it reads: a header that points outside the file, a section header table of implausible size, or a section longer than an identifier could be, is no section.

A file that is not an ELF object, or is one without the section, is drawn by the sources that follow.

4.5.4 The name #

The fourth source is the file's own name. For a directory the candidate is directory- followed by the name; for anything else it is file- followed by the name; in both the name is converted to lowercase ASCII first. If the result is not in the form of an identifier, which is so for any name with a space or a non-ASCII character in it, the source yields nothing.

So a directory called Documents is drawn as directory-documents if the chain provides it, and a file called Makefile as file-makefile. Which such names a theme provides is the theme's business; a consumer MUST NOT special-case any.

4.5.5 The type #

The fifth source is the file's type, which yields identifiers as §4.6 says.

A consumer that shows a symbolic link as the thing it points to consults the sources for the target. A consumer that shows it as a link consults them for the link itself, and a link, being unable to carry an attribute, is then drawn by its name or its type. A link whose target does not exist is drawn as generic.

4.5.7 What an icon is not #

An icon is what a thing looks like, and is chosen by parties that can say anything. A consumer MUST NOT infer from a subject's icon what the subject is, what it will do, or who made it. A file drawn as a program is not thereby a program.

Edit this page