Ubuntu – Different nautilus thumbnails rendering for text files

14.04gnomenautilusthumbnails

I have Ubuntu 14.04 Gnome edition on both my laptop and the desktop; both are up-to-date but they have a different past-history of installations and upgrades.

Now, text-type thumbnails are different in the two machines, and I am unable to find where the difference is. This post: What rendering engine does Nautilus use to show HTML previews/thumbnails? seems obsolete (no entries in dconf for them), and Generate thumbnails for text? would help (but it's unanswered).

Look at this composed shot:

thumbnails for text

In the laptop the thumbnails have a small excerpt of the content of the file (the real content) while in my desktop they are simply blank.

I dug a bit around but I can't find which option/package is responsible of the laptop behavior (which I do prefer, by the way).

How can I enable the "text snapshot" in thumbnails? (And if they had syntax highlighting, like in the linked question, it would be great).

Best Answer

It seems for an icon theme to let Nautilus display the contents of plain text files as thumbnails, its sub-directory for mime types, which might be named, for example, mimes or mimetypes should have a file named text-x-preview.icon (along with an icon file named text-x-preview.png or text-x-preview.svg, etc. serving as a backdrop for the file contents thumbnail), which is actually a plain text file including settings for the thumbnail, in each sub-directory for different icon sizes (for example, 22, 24, 48).

For example, I have added ~/.local/share/icons/Nitrux/mimetypes/48/text-x-preview.icon (imported from the default Humanity icon theme) to my current icon theme, and only then it has begun displaying thumbnails for plain text files, which has the following content:

[Icon Data]
EmbeddedTextRectangle=180,100,680,900
AttachPoints=750,750|750,250|250,250|250,750

I'll hopefully try and add more information about the settings above in due course.

  • It seems having text-x-preview.icon and text-x-preview.svg (or another valid image file type) in the sub-directory for size 48px allows Nautilus to display thumbnails for all sizes from 48px upwards, but not for sizes below 48px, for which you also need text-x-preview.icon and text-x-preview.svg (or another valid image file type) at least in the sub-directories for sizes 22px and 24px (this lets Nautilus to display thumbnails also for 16px in some but not all icon themes).

These two files in the Humanity icon theme have exactly the same content:

[Icon Data]
EmbeddedTextRectangle=180,100,680,900

NOTE: Unfortunately this whole thing no longer works under Ubuntu 15.04